diff options
author | Michel Dänzer <mdaenzer@redhat.com> | 2020-07-03 17:27:42 +0200 |
---|---|---|
committer | Olivier Fourdan <ofourdan@redhat.com> | 2022-01-18 12:09:52 +0100 |
commit | 46675b1038f60542bf88f189bd7ab6445f9fe058 (patch) | |
tree | a32f5a5c14adc590617cf57812a864a189dfd7f0 /hw | |
parent | 16c4ff7806dedbb749017a69e0096bcdd25311ca (diff) |
Drop Xwin DDX and x86 MinGW-w64 cross build
(cherry picked from commit 8f480147f6b63ebc51b8dcb80e55c7b8f91dad98)
This partly reverts commit d3933a24d1abdcb56f45e6076cb84a1110674a8a.
Diffstat (limited to 'hw')
100 files changed, 0 insertions, 35018 deletions
diff --git a/hw/meson.build b/hw/meson.build index d44dac2df..98fb7d189 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -13,7 +13,3 @@ endif if build_xwayland subdir('xwayland') endif - -if build_xwin - subdir('xwin') -endif diff --git a/hw/xwin/.gitignore b/hw/xwin/.gitignore deleted file mode 100644 index bc4986cb4..000000000 --- a/hw/xwin/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -winprefslex.c -winprefsyacc.c -winprefsyacc.h diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c deleted file mode 100644 index 04cd514ab..000000000 --- a/hw/xwin/InitInput.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - - Copyright 1993, 1998 The Open Group - - Permission to use, copy, modify, distribute, and sell this software and its - documentation for any purpose is hereby granted without fee, provided that - the above copyright notice appear in all copies and that both that - copyright notice and this permission notice appear in supporting - documentation. - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - - Except as contained in this notice, the name of The Open Group shall - not be used in advertising or otherwise to promote the sale, use or - other dealings in this Software without prior written authorization - from The Open Group. - -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "dixstruct.h" -#include "inputstr.h" - -/* - * Local function prototypes - */ - -int winProcEstablishConnection(ClientPtr /* client */ ); - -/* - * Local global declarations - */ - -DeviceIntPtr g_pwinPointer; -DeviceIntPtr g_pwinKeyboard; - -/* 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) -{ -#if 0 - ErrorF("ProcessInputEvents\n"); -#endif - - mieqProcessInputEvents(); - -#if 0 - ErrorF("ProcessInputEvents - returning\n"); -#endif -} - -void -DDXRingBell(int volume, int pitch, int duration) -{ - /* winKeybdBell is used instead */ - return; -} - - -#ifdef HAS_DEVWINDOWS -static void -xwinDevWindowsHandlerNotify(int fd, int ready, void *data) -{ - /* This should process Windows messages, but instead all of that is delayed - * until the wakeup handler is called. - */ - ; -} -#endif - -/* See Porting Layer Definition - p. 17 */ -void -InitInput(int argc, char *argv[]) -{ -#if CYGDEBUG - winDebug("InitInput\n"); -#endif - - /* - * Wrap some functions at every generation of the server. - */ - if (InitialVector[2] != winProcEstablishConnection) { - winProcEstablishConnectionOrig = InitialVector[2]; - InitialVector[2] = winProcEstablishConnection; - } - - if (AllocDevicePair(serverClient, "Windows", - &g_pwinPointer, &g_pwinKeyboard, - winMouseProc, winKeybdProc, - FALSE) != Success) - FatalError("InitInput - Failed to allocate slave devices.\n"); - - mieqInit(); - - /* Initialize the mode key states */ - 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 */ - SetNotifyFd(g_fdMessageQueue, xwinDevWindowsHandlerNotify, X_NOTIFY_READ, NULL); - } -#endif - -#if CYGDEBUG - winDebug("InitInput - returning\n"); -#endif -} - -void -CloseInput(void) -{ - mieqFini(); -} diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c deleted file mode 100644 index 7a03bfb91..000000000 --- a/hw/xwin/InitOutput.c +++ /dev/null @@ -1,1026 +0,0 @@ - -/* - -Copyright 1993, 1998 The Open Group -Copyright (C) Colin Harrison 2005-2008 - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winmsg.h" -#include "winconfig.h" -#include "winprefs.h" -#ifdef DPMSExtension -#include "dpmsproc.h" -#endif -#ifdef __CYGWIN__ -#include <mntent.h> -#endif -#if defined(WIN32) -#include "xkbsrv.h" -#endif -#ifdef RELOCATE_PROJECTROOT -#pragma push_macro("Status") -#undef Status -#define Status wStatus -#include <shlobj.h> -#pragma pop_macro("Status") -typedef WINAPI HRESULT(*SHGETFOLDERPATHPROC) (HWND hwndOwner, - int nFolder, - HANDLE hToken, - DWORD dwFlags, LPTSTR pszPath); -#endif - -#include "winmonitors.h" -#include "nonsdk_extinit.h" -#include "pseudoramiX/pseudoramiX.h" - -#include "glx_extinit.h" -#ifdef XWIN_GLX_WINDOWS -#include "glx/glwindows.h" -#include "dri/windowsdri.h" -#endif -#include "winauth.h" - -/* - * References to external symbols - */ - -/* - * Function prototypes - */ - -void - winLogCommandLine(int argc, char *argv[]); - -void - winLogVersionInfo(void); - -Bool - winValidateArgs(void); - -#ifdef RELOCATE_PROJECTROOT -const char *winGetBaseDir(void); -#endif - -/* - * For the depth 24 pixmap we default to 32 bits per pixel, but - * we change this pixmap format later if we detect that the display - * is going to be running at 24 bits per pixel. - * - * FIXME: On second thought, don't DIBs only support 32 bits per pixel? - * DIBs are the underlying bitmap used for DirectDraw surfaces, so it - * seems that all pixmap formats with depth 24 would be 32 bits per pixel. - * Confirm whether depth 24 DIBs can have 24 bits per pixel, then remove/keep - * the bits per pixel adjustment and update this comment to reflect the - * situation. Harold Hunt - 2002/07/02 - */ - -static PixmapFormatRec g_PixmapFormats[] = { - {1, 1, BITMAP_SCANLINE_PAD}, - {4, 8, BITMAP_SCANLINE_PAD}, - {8, 8, BITMAP_SCANLINE_PAD}, - {15, 16, BITMAP_SCANLINE_PAD}, - {16, 16, BITMAP_SCANLINE_PAD}, - {24, 32, BITMAP_SCANLINE_PAD}, - {32, 32, BITMAP_SCANLINE_PAD} -}; - -static Bool noDriExtension; - -static const ExtensionModule xwinExtensions[] = { -#ifdef GLXEXT -#ifdef XWIN_WINDOWS_DRI - { WindowsDRIExtensionInit, "Windows-DRI", &noDriExtension }, -#endif -#endif -}; - -/* - * XwinExtensionInit - * Initialises Xwin-specific extensions. - */ -static -void XwinExtensionInit(void) -{ -#ifdef XWIN_GLX_WINDOWS - if (g_fNativeGl) { - /* install the native GL provider */ - glxWinPushNativeProvider(); - } -#endif - - LoadExtensionList(xwinExtensions, ARRAY_SIZE(xwinExtensions), TRUE); -} - -#if defined(DDXBEFORERESET) -/* - * Called right before KillAllClients when the server is going to reset, - * allows us to shutdown our separate threads cleanly. - */ - -void -ddxBeforeReset(void) -{ - winDebug("ddxBeforeReset - Hello\n"); - - winClipboardShutdown(); -} -#endif - -#if INPUTTHREAD -/** This function is called in Xserver/os/inputthread.c when starting - the input thread. */ -void -ddxInputThreadInit(void) -{ -} -#endif - -int -main(int argc, char *argv[], char *envp[]) -{ - int iReturn; - - /* Create & acquire the termination mutex */ - iReturn = pthread_mutex_init(&g_pmTerminating, NULL); - if (iReturn != 0) { - ErrorF("ddxMain - pthread_mutex_init () failed: %d\n", iReturn); - } - - iReturn = pthread_mutex_lock(&g_pmTerminating); - if (iReturn != 0) { - ErrorF("ddxMain - pthread_mutex_lock () failed: %d\n", iReturn); - } - - return dix_main(argc, argv, envp); -} - -/* See Porting Layer Definition - p. 57 */ -void -ddxGiveUp(enum ExitCode error) -{ - int i; - -#if CYGDEBUG - winDebug("ddxGiveUp\n"); -#endif - - /* 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)); - } - - /* Unload libraries for taskbar grouping */ - winPropertyStoreDestroy(); - - /* Notify the worker threads we're exiting */ - winDeinitMultiWindowWM(); - -#ifdef HAS_DEVWINDOWS - /* Close our handle to our message queue */ - if (g_fdMessageQueue != WIN_FD_INVALID) { - /* Close /dev/windows */ - close(g_fdMessageQueue); - - /* Set the file handle to invalid */ - g_fdMessageQueue = WIN_FD_INVALID; - } -#endif - - if (!g_fLogInited) { - g_pszLogFile = LogInit(g_pszLogFile, ".old"); - 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); - - { - int iReturn = pthread_mutex_unlock(&g_pmTerminating); - - winDebug("ddxGiveUp - Releasing termination mutex\n"); - - if (iReturn != 0) { - ErrorF("winMsgWindowProc - pthread_mutex_unlock () failed: %d\n", - iReturn); - } - } - - winDebug("ddxGiveUp - End\n"); -} - -#ifdef __CYGWIN__ -/* hasmntopt is currently not implemented for cygwin */ -static const char * -winCheckMntOpt(const struct mntent *mnt, const char *opt) -{ - const char *s; - size_t len; - - if (mnt == NULL) - return NULL; - if (opt == NULL) - return NULL; - if (mnt->mnt_opts == NULL) - return NULL; - - len = strlen(opt); - s = strstr(mnt->mnt_opts, opt); - if (s == NULL) - return NULL; - if ((s == mnt->mnt_opts || *(s - 1) == ',') && - (s[len] == 0 || s[len] == ',')) - return (char *) opt; - return NULL; -} - -static void -winCheckMount(void) -{ - FILE *mnt; - struct mntent *ent; - - enum { none = 0, sys_root, user_root, sys_tmp, user_tmp } - level = none, curlevel; - BOOL binary = TRUE; - - mnt = setmntent("/etc/mtab", "r"); - if (mnt == NULL) { - ErrorF("setmntent failed"); - return; - } - - while ((ent = getmntent(mnt)) != NULL) { - BOOL sys = (winCheckMntOpt(ent, "user") != NULL); - BOOL root = (strcmp(ent->mnt_dir, "/") == 0); - BOOL tmp = (strcmp(ent->mnt_dir, "/tmp") == 0); - - if (sys) { - 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 (!binary) - winMsg(X_WARNING, "/tmp mounted in textmode\n"); -} -#else -static void -winCheckMount(void) -{ -} -#endif - -#ifdef RELOCATE_PROJECTROOT -const char * -winGetBaseDir(void) -{ - static BOOL inited = FALSE; - static char buffer[MAX_PATH]; - - if (!inited) { - char *fendptr; - HMODULE module = GetModuleHandle(NULL); - DWORD size = GetModuleFileName(module, buffer, sizeof(buffer)); - - if (sizeof(buffer) > 0) - buffer[sizeof(buffer) - 1] = 0; - - fendptr = buffer + size; - while (fendptr > buffer) { - if (*fendptr == '\\' || *fendptr == '/') { - *fendptr = 0; - break; - } - fendptr--; - } - inited = TRUE; - } - return buffer; -} -#endif - -static void -winFixupPaths(void) -{ - BOOL changed_fontpath = FALSE; - MessageType font_from = X_DEFAULT; - -#ifdef RELOCATE_PROJECTROOT - const char *basedir = winGetBaseDir(); - size_t basedirlen = strlen(basedir); -#endif - -#ifdef READ_FONTDIRS - { - /* Open fontpath configuration file */ - FILE *fontdirs = fopen(ETCX11DIR "/font-dirs", "rt"); - - if (fontdirs != NULL) { - char buffer[256]; - int needs_sep = TRUE; - int comment_block = FALSE; - - /* get default fontpath */ - char *fontpath = strdup(defaultFontPath); - size_t size = strlen(fontpath); - - /* read all lines */ - while (!feof(fontdirs)) { - size_t blen; - char *hashchar; - char *str; - int has_eol = FALSE; - - /* read one line */ - str = fgets(buffer, sizeof(buffer), fontdirs); - if (str == NULL) /* stop on error or eof */ - break; - - if (strchr(str, '\n') != NULL) - has_eol = TRUE; - - /* check if block is continued comment */ - if (comment_block) { - /* ignore all input */ - *str = 0; - blen = 0; - if (has_eol) /* check if line ended in this block */ - comment_block = FALSE; - } - else { - /* find comment character. ignore all trailing input */ - hashchar = strchr(str, '#'); - if (hashchar != NULL) { - *hashchar = 0; - if (!has_eol) /* mark next block as continued comment */ - comment_block = TRUE; - } - } - - /* strip whitespaces from beginning */ - while (*str == ' ' || *str == '\t') - str++; - - /* get size, strip whitespaces from end */ - blen = strlen(str); - while (blen > 0 && (str[blen - 1] == ' ' || - str[blen - 1] == '\t' || - str[blen - 1] == '\n')) { - str[--blen] = 0; - } - - /* still something left to add? */ - if (blen > 0) { - size_t newsize = size + blen; - - /* reserve one character more for ',' */ - if (needs_sep) - newsize++; - - /* allocate memory */ - if (fontpath == NULL) - fontpath = malloc(newsize + 1); - else - fontpath = realloc(fontpath, newsize + 1); - - /* add separator */ - if (needs_sep) { - fontpath[size] = ','; - size++; - needs_sep = FALSE; - } - - /* mark next line as new entry */ - if (has_eol) - needs_sep = TRUE; - - /* add block */ - strncpy(fontpath + size, str, blen); - fontpath[newsize] = 0; - size = newsize; - } - } - - /* cleanup */ - fclose(fontdirs); - defaultFontPath = strdup(fontpath); - free(fontpath); - changed_fontpath = TRUE; - font_from = X_CONFIG; - } - } -#endif /* READ_FONTDIRS */ -#ifdef RELOCATE_PROJECTROOT - { - const char *libx11dir = PROJECTROOT "/lib/X11"; - size_t libx11dir_len = strlen(libx11dir); - char *newfp = NULL; - size_t newfp_len = 0; - const char *endptr, *ptr, *oldptr = defaultFontPath; - - endptr = oldptr + strlen(oldptr); - ptr = strchr(oldptr, ','); - if (ptr == NULL) - ptr = endptr; - while (ptr != NULL) { - size_t oldfp_len = (ptr - oldptr); - size_t newsize = oldfp_len; - char *newpath = malloc(newsize + 1); - - strncpy(newpath, oldptr, newsize); - newpath[newsize] = 0; - - if (strncmp(libx11dir, newpath, libx11dir_len) == 0) { - char *compose; - - newsize = newsize - libx11dir_len + basedirlen; - compose = malloc(newsize + 1); - strcpy(compose, basedir); - strncat(compose, newpath + libx11dir_len, newsize - basedirlen); - compose[newsize] = 0; - free(newpath); - newpath = compose; - } - - oldfp_len = newfp_len; - if (oldfp_len > 0) - newfp_len++; /* space for separator */ - newfp_len += newsize; - - if (newfp == NULL) - newfp = malloc(newfp_len + 1); - else - newfp = realloc(newfp, newfp_len + 1); - - if (oldfp_len > 0) { - strcpy(newfp + oldfp_len, ","); - oldfp_len++; - } - strcpy(newfp + oldfp_len, newpath); - - free(newpath); - - if (*ptr == 0) { - oldptr = ptr; - ptr = NULL; - } - else { - oldptr = ptr + 1; - ptr = strchr(oldptr, ','); - if (ptr == NULL) - ptr = endptr; - } - } - - defaultFontPath = strdup(newfp); - free(newfp); - changed_fontpath = TRUE; - } -#endif /* RELOCATE_PROJECTROOT */ - if (changed_fontpath) - winMsg(font_from, "FontPath set to \"%s\"\n", defaultFontPath); - -#ifdef RELOCATE_PROJECTROOT - if (getenv("XKEYSYMDB") == NULL) { - char buffer[MAX_PATH]; - - snprintf(buffer, sizeof(buffer), "XKEYSYMDB=%s\\XKeysymDB", basedir); - buffer[sizeof(buffer) - 1] = 0; - putenv(buffer); - } - if (getenv("XERRORDB") == NULL) { - char buffer[MAX_PATH]; - - snprintf(buffer, sizeof(buffer), "XERRORDB=%s\\XErrorDB", basedir); - buffer[sizeof(buffer) - 1] = 0; - putenv(buffer); - } - if (getenv("XLOCALEDIR") == NULL) { - char buffer[MAX_PATH]; - - snprintf(buffer, sizeof(buffer), "XLOCALEDIR=%s\\locale", basedir); - buffer[sizeof(buffer) - 1] = 0; - putenv(buffer); - } - if (getenv("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) { - putenv(buffer); - } - else { - winMsg(X_ERROR, "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, - "XWin.%s.log", display); - buffer[sizeof(buffer) - 1] = 0; - g_pszLogFile = buffer; - winMsg(X_DEFAULT, "Logfile set to \"%s\"\n", g_pszLogFile); - } - } - { - static char xkbbasedir[MAX_PATH]; - - snprintf(xkbbasedir, sizeof(xkbbasedir), "%s\\xkb", basedir); - if (sizeof(xkbbasedir) > 0) - xkbbasedir[sizeof(xkbbasedir) - 1] = 0; - XkbBaseDirectory = xkbbasedir; - XkbBinDirectory = basedir; - } -#endif /* RELOCATE_PROJECTROOT */ -} - -void -OsVendorInit(void) -{ - /* Re-initialize global variables on server reset */ - winInitializeGlobals(); - - winFixupPaths(); - -#ifdef DDXOSVERRORF - if (!OsVendorVErrorFProc) - OsVendorVErrorFProc = OsVendorVErrorF; -#endif - - if (!g_fLogInited) { - /* keep this order. If LogInit fails it calls Abort which then calls - * ddxGiveUp where LogInit is called again and creates an infinite - * recursion. If we set g_fLogInited to TRUE before the init we - * avoid the second call - */ - g_fLogInited = TRUE; - g_pszLogFile = LogInit(g_pszLogFile, ".old"); - - } - 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; - winMsg(X_PROBED, - "Windows reports only %d mouse buttons, defaulting to -emulate3buttons\n", - mouseButtons); - } - } - else { - g_ScreenInfo[j].iE3BTimeout = WIN_E3B_OFF; - } - } - } - } - - /* Work out what the default resize setting should be, and apply it if it - was not explicitly specified */ - { - int j; - for (j = 0; j < g_iNumScreens; j++) { - if (g_ScreenInfo[j].iResizeMode == resizeDefault) { - if (g_ScreenInfo[j].fFullScreen) - g_ScreenInfo[j].iResizeMode = resizeNotAllowed; - else - g_ScreenInfo[j].iResizeMode = resizeWithRandr; - } - } - } -} - -static void -winUseMsg(void) -{ - ErrorF("\n"); - ErrorF("\n"); - ErrorF(EXECUTABLE_NAME " Device Dependent Usage:\n"); - ErrorF("\n"); - - ErrorF("-[no]clipboard\n" - "\tEnable [disable] the clipboard integration. Default is enabled.\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"); - - ErrorF("-[no]compositealpha\n" - "\tX windows with per-pixel alpha are composited into the Windows desktop.\n"); - ErrorF("-[no]compositewm\n" - "\tUse the Composite extension to keep a bitmap image of each top-level\n" - "\tX window, so window contents which are occluded show correctly in\n" - "\ttask bar and task switcher previews.\n"); - -#ifdef XWIN_XF86CONFIG - ErrorF("-config\n" "\tSpecify a configuration file.\n"); - - ErrorF("-configdir\n" "\tSpecify a configuration directory.\n"); -#endif - - ErrorF("-depth bits_per_pixel\n" - "\tSpecify an optional bitdepth to use in fullscreen mode\n" - "\twith a DirectDraw engine.\n"); - - ErrorF("-[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"); -#endif - - ErrorF("-engine engine_type_id\n" - "\tOverride the server's automatically selected engine type:\n" - "\t\t1 - Shadow GDI\n" - "\t\t4 - Shadow DirectDraw4 Non-Locking\n" - ); - - ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n"); - - ErrorF("-[no]hostintitle\n" - "\tIn multiwindow mode, add remote host names to window titles.\n"); - - ErrorF("-icon icon_specifier\n" "\tSet screen window icon in windowed mode.\n"); - - ErrorF("-ignoreinput\n" "\tIgnore keyboard and mouse input.\n"); - -#ifdef XWIN_XF86CONFIG - ErrorF("-keyboard\n" - "\tSpecify a keyboard device from the configuration file.\n"); -#endif - - ErrorF("-[no]keyhook\n" - "\tGrab special Windows keypresses like Alt-Tab or the Menu " - "key.\n"); - - ErrorF("-lesspointer\n" - "\tHide the windows mouse pointer when it is over any\n" - "\t" EXECUTABLE_NAME - " window. This prevents ghost cursors appearing when\n" - "\tthe Windows cursor is drawn on top of the X cursor\n"); - - ErrorF("-logfile filename\n" "\tWrite log messages to <filename>.\n"); - - ErrorF("-logverbose verbosity\n" - "\tSet the verbosity of log messages. [NOTE: Only a few messages\n" - "\trespect the settings yet]\n" - "\t\t0 - only print fatal error.\n" - "\t\t1 - print additional configuration information.\n" - "\t\t2 - print additional runtime information [default].\n" - "\t\t3 - print debugging and tracing information.\n"); - - ErrorF("-[no]multimonitors or -[no]multiplemonitors\n" - "\tUse the entire virtual screen if multiple\n" - "\tmonitors are present.\n"); - - ErrorF("-multiwindow\n" "\tRun the server in multi-window mode.\n"); - - ErrorF("-nodecoration\n" - "\tDo not draw a window border, title bar, etc. Windowed\n" - "\tmode only.\n"); - - ErrorF("-[no]primary\n" - "\tWhen clipboard integration is enabled, map the X11 PRIMARY selection\n" - "\tto the Windows clipboard. Default is enabled.\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\n" - "\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("-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("-swcursor\n" - "\tDisable the usage of the Windows cursor and use the X11 software\n" - "\tcursor instead.\n"); - - ErrorF("-[no]trayicon\n" - "\tDo not create a tray icon. Default is to create one\n" - "\ticon per screen. You can globally disable tray icons with\n" - "\t-notrayicon, then enable it for specific screens with\n" - "\t-trayicon for those screens.\n"); - - ErrorF("-[no]unixkill\n" "\tCtrl+Alt+Backspace exits the X Server.\n"); - -#ifdef XWIN_GLX_WINDOWS - ErrorF("-[no]wgl\n" - "\tEnable the GLX extension to use the native Windows WGL interface for hardware-accelerated OpenGL\n"); -#endif - - ErrorF("-[no]winkill\n" "\tAlt+F4 exits the X Server.\n"); - - ErrorF("-xkblayout XKBLayout\n" - "\tEquivalent to XKBLayout in XF86Config files.\n" - "\tFor example: -xkblayout de\n"); - - ErrorF("-xkbmodel XKBModel\n" - "\tEquivalent to XKBModel in XF86Config files.\n"); - - ErrorF("-xkboptions XKBOptions\n" - "\tEquivalent to XKBOptions in XF86Config files.\n"); - - ErrorF("-xkbrules XKBRules\n" - "\tEquivalent to XKBRules in XF86Config files.\n"); - - ErrorF("-xkbvariant XKBVariant\n" - "\tEquivalent to XKBVariant in XF86Config files.\n" - "\tFor example: -xkbvariant nodeadkeys\n"); -} - -/* See Porting Layer Definition - p. 57 */ -void -ddxUseMsg(void) -{ - /* Set a flag so that FatalError won't give duplicate warning message */ - g_fSilentFatalError = TRUE; - - winUseMsg(); - - /* Log file will not be opened for UseMsg unless we open it now */ - if (!g_fLogInited) { - g_pszLogFile = LogInit(g_pszLogFile, ".old"); - g_fLogInited = TRUE; - } - LogClose(EXIT_NO_ERROR); - - /* Notify user where UseMsg text can be found. */ - if (!g_fNoHelpMessageBox) - winMessageBoxF("The " PROJECT_NAME " help text has been printed to " - "%s.\n" - "Please open %s to read the help text.\n", - MB_ICONINFORMATION, g_pszLogFile, g_pszLogFile); -} - -/* See Porting Layer Definition - p. 20 */ -/* - * Do any global initialization, then initialize each screen. - * - * NOTE: We use ddxProcessArgument, so we don't need to touch argc and argv - */ - -void -InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[]) -{ - int i; - - if (serverGeneration == 1) - XwinExtensionInit(); - - /* Log the command line */ - winLogCommandLine(argc, argv); - -#if CYGDEBUG - winDebug("InitOutput\n"); -#endif - - /* Validate command-line arguments */ - if (serverGeneration == 1 && !winValidateArgs()) { - FatalError("InitOutput - Invalid command-line arguments found. " - "Exiting.\n"); - } - -#ifdef XWIN_XF86CONFIG - /* Try to read the xorg.conf-style configuration file */ - if (!winReadConfigfile()) - winErrorFVerb(1, "InitOutput - Error reading config file\n"); -#else - winMsg(X_INFO, "xorg.conf is not supported\n"); - winMsg(X_INFO, "See http://x.cygwin.com/docs/faq/cygwin-x-faq.html " - "for more information\n"); - winConfigFiles(); -#endif - - /* Load preferences from XWinrc file */ - LoadPreferences(); - - /* Setup global screen info parameters */ - pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; - pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; - pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; - pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; - pScreenInfo->numPixmapFormats = ARRAY_SIZE(g_PixmapFormats); - - /* Describe how we want common pixmap formats padded */ - for (i = 0; i < ARRAY_SIZE(g_PixmapFormats); i++) { - pScreenInfo->formats[i] = g_PixmapFormats[i]; - } - - /* Load pointers to DirectDraw functions */ - winGetDDProcAddresses(); - - /* Detect supported engines */ - winDetectSupportedEngines(); - /* Load libraries for taskbar grouping */ - winPropertyStoreInit(); - - /* Store the instance handle */ - g_hInstance = GetModuleHandle(NULL); - - /* Create the messaging window */ - if (serverGeneration == 1) - winCreateMsgWindowThread(); - - /* 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); - } - } - - /* - Unless full xinerama has been explicitly enabled, register all native screens with pseudoramiX - */ - if (!noPanoramiXExtension) - noPseudoramiXExtension = TRUE; - - if ((g_ScreenInfo[0].fMultipleMonitors) && !noPseudoramiXExtension) - { - int pass; - - PseudoramiXExtensionInit(); - - /* Add primary monitor on pass 0, other monitors on pass 1, to ensure - the primary monitor is first in XINERAMA list */ - for (pass = 0; pass < 2; pass++) - { - int iMonitor; - - for (iMonitor = 1; ; iMonitor++) - { - struct GetMonitorInfoData data; - if (QueryMonitor(iMonitor, &data)) - { - MONITORINFO mi; - mi.cbSize = sizeof(MONITORINFO); - - if (GetMonitorInfo(data.monitorHandle, &mi)) - { - /* pass == 1 XOR primary monitor flags is set */ - if ((!(pass == 1)) != (!(mi.dwFlags & MONITORINFOF_PRIMARY))) - { - /* - Note the screen origin in a normalized coordinate space where (0,0) is at the top left - of the native virtual desktop area - */ - data.monitorOffsetX = data.monitorOffsetX - GetSystemMetrics(SM_XVIRTUALSCREEN); - data.monitorOffsetY = data.monitorOffsetY - GetSystemMetrics(SM_YVIRTUALSCREEN); - - winDebug ("InitOutput - screen %d added at virtual desktop coordinate (%d,%d) (pseudoramiX) \n", - iMonitor-1, data.monitorOffsetX, data.monitorOffsetY); - - PseudoramiXAddScreen(data.monitorOffsetX, data.monitorOffsetY, - data.monitorWidth, data.monitorHeight); - } - } - } - else - break; - } - } - } - - xorgGlxCreateVendor(); - - /* Generate a cookie used by internal clients for authorization */ - if (g_fXdmcpEnabled || g_fAuthEnabled) - winGenerateAuthorization(); - - -#if CYGDEBUG || YES - winDebug("InitOutput - Returning.\n"); -#endif -} diff --git a/hw/xwin/X.ico b/hw/xwin/X.ico Binary files differdeleted file mode 100644 index 5d69818b5..000000000 --- a/hw/xwin/X.ico +++ /dev/null diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest deleted file mode 100755 index bd44b1066..000000000 --- a/hw/xwin/XWin.exe.manifest +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <description>The XWin X Windows server</description> - <dependency> - <dependentAssembly> - <assemblyIdentity - type="win32" - name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" - processorArchitecture="*" - publicKeyToken="6595b64144ccf1df" - language="*" - /> - </dependentAssembly> - </dependency> - <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> - <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> - <dpiAware>true</dpiAware> - </asmv3:windowsSettings> - </asmv3:application> - <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> - <application> - <!-- Windows Vista --> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> - <!-- Windows 7 --> - <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> - <!-- Windows 8 --> - <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> - <!-- Windows 8.1 --> - <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> - <!-- Windows 10 --> - <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> - </application> - </compatibility> -</assembly> diff --git a/hw/xwin/XWin.rc b/hw/xwin/XWin.rc deleted file mode 100644 index a54e0fdbb..000000000 --- a/hw/xwin/XWin.rc +++ /dev/null @@ -1,109 +0,0 @@ -/* - *Copyright (C) 2002-2004 Harold L Hunt II All Rights Reserved. - *Copyright (C) 2008 Yaakov Selkowitz All Rights Reserved - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the names of the authors - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the authors. - * - * Authors: Harold L Hunt II, Yaakov Selkowitz - */ - -#include <windows.h> -#include "winresource.h" -#include "xwin-config.h" -#include "version-config.h" - -/* - * Dialogs - */ - -/* About */ -ABOUT_BOX DIALOGEX 32, 32, 260, 105 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE -CAPTION "About " XVENDORNAMESHORT -FONT 8, "MS Shell Dlg 2" -BEGIN - CONTROL IDI_XWIN, IDC_STATIC, "Static", SS_ICON, 8, 8, 32, 32 - LTEXT XVENDORNAMESHORT " X Server ", IDC_STATIC, 36, 8, 220, 8 - LTEXT VENDOR_MAN_VERSION, IDC_STATIC, 36, 18, 220, 8 - LTEXT BUILDERSTRING, IDC_STATIC, 36, 28, 220, 8 - LTEXT "This software is licensed under the terms of the MIT/X11 License.", IDC_STATIC, 36, 48, 220, 20 - CONTROL __VENDORDWEBSUPPORT__, ID_ABOUT_WEBSITE, "Button", - BS_OWNERDRAW | WS_TABSTOP, 36, 68, 220, 8 - DEFPUSHBUTTON "&OK", IDOK, 105, 85, 50, 15 -END - - -/* Depth change */ - -DEPTH_CHANGE_BOX DIALOGEX 32, 32, 180, 100 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE -FONT 8, "MS Shell Dlg 2" -CAPTION XVENDORNAMESHORT -BEGIN - DEFPUSHBUTTON "Dismiss", IDOK, 66, 80, 50, 14 - CTEXT XVENDORNAMESHORT, IDC_STATIC, 40, 12, 100, 8 - CTEXT "Disruptive screen configuration change.", IDC_STATIC, 7, 40, 166, 8 - CTEXT "Restore previous resolution to use " XVENDORNAMESHORT ".", IDC_STATIC, 7, 52, 166, 8 -END - - -/* Exit */ - -EXIT_DIALOG DIALOGEX 32, 32, 180, 78 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE -FONT 8, "MS Shell Dlg 2" -CAPTION "Exit " XVENDORNAMESHORT "?" -BEGIN - PUSHBUTTON "E&xit", IDOK, 55, 56, 30, 14 - DEFPUSHBUTTON "&Cancel", IDCANCEL, 95, 56, 30, 14 - CTEXT "E&xiting will close all screens running on this display.", IDC_STATIC, 7, 12, 166, 8 - CTEXT "No information about connected clients available.", IDC_CLIENTS_CONNECTED, 7, 24, 166, 8 - CTEXT "Proceed with shutdown of this display/server?", IDC_STATIC, 7, 36, 166, 8 -END - - -/* - * Menus - */ - -IDM_TRAYICON_MENU MENU -BEGIN - POPUP "TRAYICON_MENU" - BEGIN - MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT - MENUITEM "Clipboard may use &PRIMARY selection", ID_APP_MONITOR_PRIMARY - MENUITEM "&About...", ID_APP_ABOUT - MENUITEM SEPARATOR - MENUITEM "E&xit...", ID_APP_EXIT - END -END - - -/* - * Icons - */ - -IDI_XWIN ICON "X.ico" -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "XWin.exe.manifest" diff --git a/hw/xwin/ddraw.h b/hw/xwin/ddraw.h deleted file mode 100644 index 720fa5a9c..000000000 --- a/hw/xwin/ddraw.h +++ /dev/null @@ -1,2322 +0,0 @@ -#ifdef __MINGW64_VERSION_MAJOR -#include_next <ddraw.h> -#define __XWIN_DDRAW_H -#endif -#ifndef __XWIN_DDRAW_H -#define __XWIN_DDRAW_H - -#include <winnt.h> -#include <wingdi.h> -#include <objbase.h> - -#if defined(NONAMELESSUNION) && !defined(DUMMYUNIONNAME1) -#define DUMMYUNIONNAME1 u1 -#endif - -#define ICOM_CALL_( xfn, p, args) (p)->lpVtbl->xfn args - -#ifdef UNICODE -#define WINELIB_NAME_AW(func) func##W -#else -#define WINELIB_NAME_AW(func) func##A -#endif /* UNICODE */ -#define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type; - -#ifdef __cplusplus -extern "C" { -#endif /* defined(__cplusplus) */ - -#ifndef DIRECTDRAW_VERSION -#define DIRECTDRAW_VERSION 0x0700 -#endif /* DIRECTDRAW_VERSION */ - -/***************************************************************************** - * Predeclare the interfaces - */ - DEFINE_GUID(CLSID_DirectDraw, 0xD7B70EE0, 0x4340, 0x11CF, 0xB0, 0x63, 0x00, - 0x20, 0xAF, 0xC2, 0xCD, 0x35); - DEFINE_GUID(CLSID_DirectDraw7, 0x3C305196, 0x50DB, 0x11D3, 0x9C, 0xFE, 0x00, - 0xC0, 0x4F, 0xD9, 0x30, 0xC5); - DEFINE_GUID(CLSID_DirectDrawClipper, 0x593817A0, 0x7DB3, 0x11CF, 0xA2, 0xDE, - 0x00, 0xAA, 0x00, 0xb9, 0x33, 0x56); - DEFINE_GUID(IID_IDirectDraw, 0x6C14DB80, 0xA733, 0x11CE, 0xA5, 0x21, 0x00, - 0x20, 0xAF, 0x0B, 0xE5, 0x60); - DEFINE_GUID(IID_IDirectDraw2, 0xB3A6F3E0, 0x2B43, 0x11CF, 0xA2, 0xDE, 0x00, - 0xAA, 0x00, 0xB9, 0x33, 0x56); - DEFINE_GUID(IID_IDirectDraw4, 0x9c59509a, 0x39bd, 0x11d1, 0x8c, 0x4a, 0x00, - 0xc0, 0x4f, 0xd9, 0x30, 0xc5); - DEFINE_GUID(IID_IDirectDraw7, 0x15e65ec0, 0x3b9c, 0x11d2, 0xb9, 0x2f, 0x00, - 0x60, 0x97, 0x97, 0xea, 0x5b); - DEFINE_GUID(IID_IDirectDrawSurface, 0x6C14DB81, 0xA733, 0x11CE, 0xA5, 0x21, - 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - DEFINE_GUID(IID_IDirectDrawSurface2, 0x57805885, 0x6eec, 0x11cf, 0x94, 0x41, - 0xa8, 0x23, 0x03, 0xc1, 0x0e, 0x27); - DEFINE_GUID(IID_IDirectDrawSurface3, 0xDA044E00, 0x69B2, 0x11D0, 0xA1, 0xD5, - 0x00, 0xAA, 0x00, 0xB8, 0xDF, 0xBB); - DEFINE_GUID(IID_IDirectDrawSurface4, 0x0B2B8630, 0xAD35, 0x11D0, 0x8E, 0xA6, - 0x00, 0x60, 0x97, 0x97, 0xEA, 0x5B); - DEFINE_GUID(IID_IDirectDrawSurface7, 0x06675a80, 0x3b9b, 0x11d2, 0xb9, 0x2f, - 0x00, 0x60, 0x97, 0x97, 0xea, 0x5b); - DEFINE_GUID(IID_IDirectDrawPalette, 0x6C14DB84, 0xA733, 0x11CE, 0xA5, 0x21, - 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - DEFINE_GUID(IID_IDirectDrawClipper, 0x6C14DB85, 0xA733, 0x11CE, 0xA5, 0x21, - 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60); - DEFINE_GUID(IID_IDirectDrawColorControl, 0x4B9F0EE0, 0x0D7E, 0x11D0, 0x9B, - 0x06, 0x00, 0xA0, 0xC9, 0x03, 0xA3, 0xB8); - DEFINE_GUID(IID_IDirectDrawGammaControl, 0x69C11C3E, 0xB46B, 0x11D1, 0xAD, - 0x7A, 0x00, 0xC0, 0x4F, 0xC2, 0x9B, 0x4E); - - typedef struct IDirectDraw *LPDIRECTDRAW; - typedef struct IDirectDraw2 *LPDIRECTDRAW2; - typedef struct IDirectDraw4 *LPDIRECTDRAW4; - typedef struct IDirectDraw7 *LPDIRECTDRAW7; - typedef struct IDirectDrawClipper *LPDIRECTDRAWCLIPPER; - typedef struct IDirectDrawPalette *LPDIRECTDRAWPALETTE; - typedef struct IDirectDrawSurface *LPDIRECTDRAWSURFACE; - typedef struct IDirectDrawSurface2 *LPDIRECTDRAWSURFACE2; - typedef struct IDirectDrawSurface3 *LPDIRECTDRAWSURFACE3; - typedef struct IDirectDrawSurface4 *LPDIRECTDRAWSURFACE4; - typedef struct IDirectDrawSurface7 *LPDIRECTDRAWSURFACE7; - typedef struct IDirectDrawColorControl *LPDIRECTDRAWCOLORCONTROL; - typedef struct IDirectDrawGammaControl *LPDIRECTDRAWGAMMACONTROL; - -#define DDENUMRET_CANCEL 0 -#define DDENUMRET_OK 1 - -#define DD_OK 0 - -#define _FACDD 0x876 -#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) - -#define DDERR_ALREADYINITIALIZED MAKE_DDHRESULT( 5 ) -#define DDERR_CANNOTATTACHSURFACE MAKE_DDHRESULT( 10 ) -#define DDERR_CANNOTDETACHSURFACE MAKE_DDHRESULT( 20 ) -#define DDERR_CURRENTLYNOTAVAIL MAKE_DDHRESULT( 40 ) -#define DDERR_EXCEPTION MAKE_DDHRESULT( 55 ) -#define DDERR_GENERIC E_FAIL -#define DDERR_HEIGHTALIGN MAKE_DDHRESULT( 90 ) -#define DDERR_INCOMPATIBLEPRIMARY MAKE_DDHRESULT( 95 ) -#define DDERR_INVALIDCAPS MAKE_DDHRESULT( 100 ) -#define DDERR_INVALIDCLIPLIST MAKE_DDHRESULT( 110 ) -#define DDERR_INVALIDMODE MAKE_DDHRESULT( 120 ) -#define DDERR_INVALIDOBJECT MAKE_DDHRESULT( 130 ) -#define DDERR_INVALIDPARAMS E_INVALIDARG -#define DDERR_INVALIDPIXELFORMAT MAKE_DDHRESULT( 145 ) -#define DDERR_INVALIDRECT MAKE_DDHRESULT( 150 ) -#define DDERR_LOCKEDSURFACES MAKE_DDHRESULT( 160 ) -#define DDERR_NO3D MAKE_DDHRESULT( 170 ) -#define DDERR_NOALPHAHW MAKE_DDHRESULT( 180 ) -#define DDERR_NOSTEREOHARDWARE MAKE_DDHRESULT( 181 ) -#define DDERR_NOSURFACELEFT MAKE_DDHRESULT( 182 ) -#define DDERR_NOCLIPLIST MAKE_DDHRESULT( 205 ) -#define DDERR_NOCOLORCONVHW MAKE_DDHRESULT( 210 ) -#define DDERR_NOCOOPERATIVELEVELSET MAKE_DDHRESULT( 212 ) -#define DDERR_NOCOLORKEY MAKE_DDHRESULT( 215 ) -#define DDERR_NOCOLORKEYHW MAKE_DDHRESULT( 220 ) -#define DDERR_NODIRECTDRAWSUPPORT MAKE_DDHRESULT( 222 ) -#define DDERR_NOEXCLUSIVEMODE MAKE_DDHRESULT( 225 ) -#define DDERR_NOFLIPHW MAKE_DDHRESULT( 230 ) -#define DDERR_NOGDI MAKE_DDHRESULT( 240 ) -#define DDERR_NOMIRRORHW MAKE_DDHRESULT( 250 ) -#define DDERR_NOTFOUND MAKE_DDHRESULT( 255 ) -#define DDERR_NOOVERLAYHW MAKE_DDHRESULT( 260 ) -#define DDERR_OVERLAPPINGRECTS MAKE_DDHRESULT( 270 ) -#define DDERR_NORASTEROPHW MAKE_DDHRESULT( 280 ) -#define DDERR_NOROTATIONHW MAKE_DDHRESULT( 290 ) -#define DDERR_NOSTRETCHHW MAKE_DDHRESULT( 310 ) -#define DDERR_NOT4BITCOLOR MAKE_DDHRESULT( 316 ) -#define DDERR_NOT4BITCOLORINDEX MAKE_DDHRESULT( 317 ) -#define DDERR_NOT8BITCOLOR MAKE_DDHRESULT( 320 ) -#define DDERR_NOTEXTUREHW MAKE_DDHRESULT( 330 ) -#define DDERR_NOVSYNCHW MAKE_DDHRESULT( 335 ) -#define DDERR_NOZBUFFERHW MAKE_DDHRESULT( 340 ) -#define DDERR_NOZOVERLAYHW MAKE_DDHRESULT( 350 ) -#define DDERR_OUTOFCAPS MAKE_DDHRESULT( 360 ) -#define DDERR_OUTOFMEMORY E_OUTOFMEMORY -#define DDERR_OUTOFVIDEOMEMORY MAKE_DDHRESULT( 380 ) -#define DDERR_OVERLAYCANTCLIP MAKE_DDHRESULT( 382 ) -#define DDERR_OVERLAYCOLORKEYONLYONEACTIVE MAKE_DDHRESULT( 384 ) -#define DDERR_PALETTEBUSY MAKE_DDHRESULT( 387 ) -#define DDERR_COLORKEYNOTSET MAKE_DDHRESULT( 400 ) -#define DDERR_SURFACEALREADYATTACHED MAKE_DDHRESULT( 410 ) -#define DDERR_SURFACEALREADYDEPENDENT MAKE_DDHRESULT( 420 ) -#define DDERR_SURFACEBUSY MAKE_DDHRESULT( 430 ) -#define DDERR_CANTLOCKSURFACE MAKE_DDHRESULT( 435 ) -#define DDERR_SURFACEISOBSCURED MAKE_DDHRESULT( 440 ) -#define DDERR_SURFACELOST MAKE_DDHRESULT( 450 ) -#define DDERR_SURFACENOTATTACHED MAKE_DDHRESULT( 460 ) -#define DDERR_TOOBIGHEIGHT MAKE_DDHRESULT( 470 ) -#define DDERR_TOOBIGSIZE MAKE_DDHRESULT( 480 ) -#define DDERR_TOOBIGWIDTH MAKE_DDHRESULT( 490 ) -#define DDERR_UNSUPPORTED E_NOTIMPL -#define DDERR_UNSUPPORTEDFORMAT MAKE_DDHRESULT( 510 ) -#define DDERR_UNSUPPORTEDMASK MAKE_DDHRESULT( 520 ) -#define DDERR_INVALIDSTREAM MAKE_DDHRESULT( 521 ) -#define DDERR_VERTICALBLANKINPROGRESS MAKE_DDHRESULT( 537 ) -#define DDERR_WASSTILLDRAWING MAKE_DDHRESULT( 540 ) -#define DDERR_DDSCAPSCOMPLEXREQUIRED MAKE_DDHRESULT( 542 ) -#define DDERR_XALIGN MAKE_DDHRESULT( 560 ) -#define DDERR_INVALIDDIRECTDRAWGUID MAKE_DDHRESULT( 561 ) -#define DDERR_DIRECTDRAWALREADYCREATED MAKE_DDHRESULT( 562 ) -#define DDERR_NODIRECTDRAWHW MAKE_DDHRESULT( 563 ) -#define DDERR_PRIMARYSURFACEALREADYEXISTS MAKE_DDHRESULT( 564 ) -#define DDERR_NOEMULATION MAKE_DDHRESULT( 565 ) -#define DDERR_REGIONTOOSMALL MAKE_DDHRESULT( 566 ) -#define DDERR_CLIPPERISUSINGHWND MAKE_DDHRESULT( 567 ) -#define DDERR_NOCLIPPERATTACHED MAKE_DDHRESULT( 568 ) -#define DDERR_NOHWND MAKE_DDHRESULT( 569 ) -#define DDERR_HWNDSUBCLASSED MAKE_DDHRESULT( 570 ) -#define DDERR_HWNDALREADYSET MAKE_DDHRESULT( 571 ) -#define DDERR_NOPALETTEATTACHED MAKE_DDHRESULT( 572 ) -#define DDERR_NOPALETTEHW MAKE_DDHRESULT( 573 ) -#define DDERR_BLTFASTCANTCLIP MAKE_DDHRESULT( 574 ) -#define DDERR_NOBLTHW MAKE_DDHRESULT( 575 ) -#define DDERR_NODDROPSHW MAKE_DDHRESULT( 576 ) -#define DDERR_OVERLAYNOTVISIBLE MAKE_DDHRESULT( 577 ) -#define DDERR_NOOVERLAYDEST MAKE_DDHRESULT( 578 ) -#define DDERR_INVALIDPOSITION MAKE_DDHRESULT( 579 ) -#define DDERR_NOTAOVERLAYSURFACE MAKE_DDHRESULT( 580 ) -#define DDERR_EXCLUSIVEMODEALREADYSET MAKE_DDHRESULT( 581 ) -#define DDERR_NOTFLIPPABLE MAKE_DDHRESULT( 582 ) -#define DDERR_CANTDUPLICATE MAKE_DDHRESULT( 583 ) -#define DDERR_NOTLOCKED MAKE_DDHRESULT( 584 ) -#define DDERR_CANTCREATEDC MAKE_DDHRESULT( 585 ) -#define DDERR_NODC MAKE_DDHRESULT( 586 ) -#define DDERR_WRONGMODE MAKE_DDHRESULT( 587 ) -#define DDERR_IMPLICITLYCREATED MAKE_DDHRESULT( 588 ) -#define DDERR_NOTPALETTIZED MAKE_DDHRESULT( 589 ) -#define DDERR_UNSUPPORTEDMODE MAKE_DDHRESULT( 590 ) -#define DDERR_NOMIPMAPHW MAKE_DDHRESULT( 591 ) -#define DDERR_INVALIDSURFACETYPE MAKE_DDHRESULT( 592 ) -#define DDERR_NOOPTIMIZEHW MAKE_DDHRESULT( 600 ) -#define DDERR_NOTLOADED MAKE_DDHRESULT( 601 ) -#define DDERR_NOFOCUSWINDOW MAKE_DDHRESULT( 602 ) -#define DDERR_NOTONMIPMAPSUBLEVEL MAKE_DDHRESULT( 603 ) -#define DDERR_DCALREADYCREATED MAKE_DDHRESULT( 620 ) -#define DDERR_NONONLOCALVIDMEM MAKE_DDHRESULT( 630 ) -#define DDERR_CANTPAGELOCK MAKE_DDHRESULT( 640 ) -#define DDERR_CANTPAGEUNLOCK MAKE_DDHRESULT( 660 ) -#define DDERR_NOTPAGELOCKED MAKE_DDHRESULT( 680 ) -#define DDERR_MOREDATA MAKE_DDHRESULT( 690 ) -#define DDERR_EXPIRED MAKE_DDHRESULT( 691 ) -#define DDERR_TESTFINISHED MAKE_DDHRESULT( 692 ) -#define DDERR_NEWMODE MAKE_DDHRESULT( 693 ) -#define DDERR_D3DNOTINITIALIZED MAKE_DDHRESULT( 694 ) -#define DDERR_VIDEONOTACTIVE MAKE_DDHRESULT( 695 ) -#define DDERR_NOMONITORINFORMATION MAKE_DDHRESULT( 696 ) -#define DDERR_NODRIVERSUPPORT MAKE_DDHRESULT( 697 ) -#define DDERR_DEVICEDOESNTOWNSURFACE MAKE_DDHRESULT( 699 ) -#define DDERR_NOTINITIALIZED CO_E_NOTINITIALIZED - -/* dwFlags for Blt* */ -#define DDBLT_ALPHADEST 0x00000001 -#define DDBLT_ALPHADESTCONSTOVERRIDE 0x00000002 -#define DDBLT_ALPHADESTNEG 0x00000004 -#define DDBLT_ALPHADESTSURFACEOVERRIDE 0x00000008 -#define DDBLT_ALPHAEDGEBLEND 0x00000010 -#define DDBLT_ALPHASRC 0x00000020 -#define DDBLT_ALPHASRCCONSTOVERRIDE 0x00000040 -#define DDBLT_ALPHASRCNEG 0x00000080 -#define DDBLT_ALPHASRCSURFACEOVERRIDE 0x00000100 -#define DDBLT_ASYNC 0x00000200 -#define DDBLT_COLORFILL 0x00000400 -#define DDBLT_DDFX 0x00000800 -#define DDBLT_DDROPS 0x00001000 -#define DDBLT_KEYDEST 0x00002000 -#define DDBLT_KEYDESTOVERRIDE 0x00004000 -#define DDBLT_KEYSRC 0x00008000 -#define DDBLT_KEYSRCOVERRIDE 0x00010000 -#define DDBLT_ROP 0x00020000 -#define DDBLT_ROTATIONANGLE 0x00040000 -#define DDBLT_ZBUFFER 0x00080000 -#define DDBLT_ZBUFFERDESTCONSTOVERRIDE 0x00100000 -#define DDBLT_ZBUFFERDESTOVERRIDE 0x00200000 -#define DDBLT_ZBUFFERSRCCONSTOVERRIDE 0x00400000 -#define DDBLT_ZBUFFERSRCOVERRIDE 0x00800000 -#define DDBLT_WAIT 0x01000000 -#define DDBLT_DEPTHFILL 0x02000000 -#define DDBLT_DONOTWAIT 0x08000000 - -/* dwTrans for BltFast */ -#define DDBLTFAST_NOCOLORKEY 0x00000000 -#define DDBLTFAST_SRCCOLORKEY 0x00000001 -#define DDBLTFAST_DESTCOLORKEY 0x00000002 -#define DDBLTFAST_WAIT 0x00000010 -#define DDBLTFAST_DONOTWAIT 0x00000020 - -/* dwFlags for Flip */ -#define DDFLIP_WAIT 0x00000001 -#define DDFLIP_EVEN 0x00000002 /* only valid for overlay */ -#define DDFLIP_ODD 0x00000004 /* only valid for overlay */ -#define DDFLIP_NOVSYNC 0x00000008 -#define DDFLIP_STEREO 0x00000010 -#define DDFLIP_DONOTWAIT 0x00000020 - -/* dwFlags for GetBltStatus */ -#define DDGBS_CANBLT 0x00000001 -#define DDGBS_ISBLTDONE 0x00000002 - -/* dwFlags for IDirectDrawSurface7::GetFlipStatus */ -#define DDGFS_CANFLIP 1L -#define DDGFS_ISFLIPDONE 2L - -/* dwFlags for IDirectDrawSurface7::SetPrivateData */ -#define DDSPD_IUNKNOWNPTR 1L -#define DDSPD_VOLATILE 2L - -/* DDSCAPS.dwCaps */ -/* reserved1, was 3d capable */ -#define DDSCAPS_RESERVED1 0x00000001 -/* surface contains alpha information */ -#define DDSCAPS_ALPHA 0x00000002 -/* this surface is a backbuffer */ -#define DDSCAPS_BACKBUFFER 0x00000004 -/* complex surface structure */ -#define DDSCAPS_COMPLEX 0x00000008 -/* part of surface flipping structure */ -#define DDSCAPS_FLIP 0x00000010 -/* this surface is the frontbuffer surface */ -#define DDSCAPS_FRONTBUFFER 0x00000020 -/* this is a plain offscreen surface */ -#define DDSCAPS_OFFSCREENPLAIN 0x00000040 -/* overlay */ -#define DDSCAPS_OVERLAY 0x00000080 -/* palette objects can be created and attached to us */ -#define DDSCAPS_PALETTE 0x00000100 -/* primary surface (the one the user looks at currently)(right eye)*/ -#define DDSCAPS_PRIMARYSURFACE 0x00000200 -/* primary surface for left eye */ -#define DDSCAPS_PRIMARYSURFACELEFT 0x00000400 -/* surface exists in systemmemory */ -#define DDSCAPS_SYSTEMMEMORY 0x00000800 -/* surface can be used as a texture */ -#define DDSCAPS_TEXTURE 0x00001000 -/* surface may be destination for 3d rendering */ -#define DDSCAPS_3DDEVICE 0x00002000 -/* surface exists in videomemory */ -#define DDSCAPS_VIDEOMEMORY 0x00004000 -/* surface changes immediately visible */ -#define DDSCAPS_VISIBLE 0x00008000 -/* write only surface */ -#define DDSCAPS_WRITEONLY 0x00010000 -/* zbuffer surface */ -#define DDSCAPS_ZBUFFER 0x00020000 -/* has its own DC */ -#define DDSCAPS_OWNDC 0x00040000 -/* surface should be able to receive live video */ -#define DDSCAPS_LIVEVIDEO 0x00080000 -/* should be able to have a hw codec decompress stuff into it */ -#define DDSCAPS_HWCODEC 0x00100000 -/* mode X (320x200 or 320x240) surface */ -#define DDSCAPS_MODEX 0x00200000 -/* one mipmap surface (1 level) */ -#define DDSCAPS_MIPMAP 0x00400000 -#define DDSCAPS_RESERVED2 0x00800000 -/* memory allocation delayed until Load() */ -#define DDSCAPS_ALLOCONLOAD 0x04000000 -/* Indicates that the surface will receive data from a video port */ -#define DDSCAPS_VIDEOPORT 0x08000000 -/* surface is in local videomemory */ -#define DDSCAPS_LOCALVIDMEM 0x10000000 -/* surface is in nonlocal videomemory */ -#define DDSCAPS_NONLOCALVIDMEM 0x20000000 -/* surface is a standard VGA mode surface (NOT ModeX) */ -#define DDSCAPS_STANDARDVGAMODE 0x40000000 -/* optimized? surface */ -#define DDSCAPS_OPTIMIZED 0x80000000 - - typedef struct _DDSCAPS { - DWORD dwCaps; /* capabilities of surface wanted */ - } DDSCAPS, *LPDDSCAPS; - -/* DDSCAPS2.dwCaps2 */ -/* indicates the surface will receive data from a video port using - deinterlacing hardware. */ -#define DDSCAPS2_HARDWAREDEINTERLACE 0x00000002 -/* indicates the surface will be locked very frequently. */ -#define DDSCAPS2_HINTDYNAMIC 0x00000004 -/* indicates surface can be re-ordered or retiled on load() */ -#define DDSCAPS2_HINTSTATIC 0x00000008 -/* indicates surface to be managed by directdraw/direct3D */ -#define DDSCAPS2_TEXTUREMANAGE 0x00000010 -/* reserved bits */ -#define DDSCAPS2_RESERVED1 0x00000020 -#define DDSCAPS2_RESERVED2 0x00000040 -/* indicates surface will never be locked again */ -#define DDSCAPS2_OPAQUE 0x00000080 -/* set at CreateSurface() time to indicate antialiasing will be used */ -#define DDSCAPS2_HINTANTIALIASING 0x00000100 -/* set at CreateSurface() time to indicate cubic environment map */ -#define DDSCAPS2_CUBEMAP 0x00000200 -/* face flags for cube maps */ -#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400 -#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800 -#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000 -#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000 -#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000 -#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000 -/* specifies all faces of a cube for CreateSurface() */ -#define DDSCAPS2_CUBEMAP_ALLFACES ( DDSCAPS2_CUBEMAP_POSITIVEX |\ - DDSCAPS2_CUBEMAP_NEGATIVEX |\ - DDSCAPS2_CUBEMAP_POSITIVEY |\ - DDSCAPS2_CUBEMAP_NEGATIVEY |\ - DDSCAPS2_CUBEMAP_POSITIVEZ |\ - DDSCAPS2_CUBEMAP_NEGATIVEZ ) -/* set for mipmap sublevels on DirectX7 and later. ignored by CreateSurface() */ -#define DDSCAPS2_MIPMAPSUBLEVEL 0x00010000 -/* indicates texture surface to be managed by Direct3D *only* */ -#define DDSCAPS2_D3DTEXTUREMANAGE 0x00020000 -/* indicates managed surface that can safely be lost */ -#define DDSCAPS2_DONOTPERSIST 0x00040000 -/* indicates surface is part of a stereo flipping chain */ -#define DDSCAPS2_STEREOSURFACELEFT 0x00080000 - - typedef struct _DDSCAPS2 { - DWORD dwCaps; /* capabilities of surface wanted */ - DWORD dwCaps2; /* additional capabilities */ - DWORD dwCaps3; /* reserved capabilities */ - DWORD dwCaps4; /* more reserved capabilities */ - } DDSCAPS2, *LPDDSCAPS2; - -#define DD_ROP_SPACE (256/32) /* space required to store ROP array */ - - typedef struct _DDCAPS_DX7 { /* DirectX 7 version of caps struct */ - DWORD dwSize; /* size of the DDDRIVERCAPS structure */ - DWORD dwCaps; /* driver specific capabilities */ - DWORD dwCaps2; /* more driver specific capabilities */ - DWORD dwCKeyCaps; /* color key capabilities of the surface */ - DWORD dwFXCaps; /* driver specific stretching and effects capabilities */ - DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */ - DWORD dwPalCaps; /* palette capabilities */ - DWORD dwSVCaps; /* stereo vision capabilities */ - DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */ - DWORD dwVidMemTotal; /* total amount of video memory */ - DWORD dwVidMemFree; /* amount of free video memory */ - DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */ - DWORD dwCurrVisibleOverlays; /* current number of visible overlays */ - DWORD dwNumFourCCCodes; /* number of four cc codes */ - DWORD dwAlignBoundarySrc; /* source rectangle alignment */ - DWORD dwAlignSizeSrc; /* source rectangle byte size */ - DWORD dwAlignBoundaryDest; /* dest rectangle alignment */ - DWORD dwAlignSizeDest; /* dest rectangle byte size */ - DWORD dwAlignStrideAlign; /* stride alignment */ - DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */ - DDSCAPS ddsOldCaps; /* old DDSCAPS - superseded for DirectX6+ */ - DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwReserved1; - DWORD dwReserved2; - DWORD dwReserved3; - DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */ - DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */ - DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */ - DWORD dwSVBRops[DD_ROP_SPACE]; /* ROPS supported for System->Vmem blts */ - DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */ - DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */ - DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */ - DWORD dwVSBRops[DD_ROP_SPACE]; /* ROPS supported for Vmem->System blts */ - DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */ - DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */ - DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */ - DWORD dwSSBRops[DD_ROP_SPACE]; /* ROPS supported for System->System blts */ - DWORD dwMaxVideoPorts; /* maximum number of usable video ports */ - DWORD dwCurrVideoPorts; /* current number of video ports used */ - DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */ - DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */ - DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */ - DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */ - DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */ - DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */ - DDSCAPS2 ddsCaps; /* surface capabilities */ - } DDCAPS_DX7, *LPDDCAPS_DX7; - - typedef struct _DDCAPS_DX6 { /* DirectX 6 version of caps struct */ - DWORD dwSize; /* size of the DDDRIVERCAPS structure */ - DWORD dwCaps; /* driver specific capabilities */ - DWORD dwCaps2; /* more driver specific capabilities */ - DWORD dwCKeyCaps; /* color key capabilities of the surface */ - DWORD dwFXCaps; /* driver specific stretching and effects capabilities */ - DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */ - DWORD dwPalCaps; /* palette capabilities */ - DWORD dwSVCaps; /* stereo vision capabilities */ - DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */ - DWORD dwVidMemTotal; /* total amount of video memory */ - DWORD dwVidMemFree; /* amount of free video memory */ - DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */ - DWORD dwCurrVisibleOverlays; /* current number of visible overlays */ - DWORD dwNumFourCCCodes; /* number of four cc codes */ - DWORD dwAlignBoundarySrc; /* source rectangle alignment */ - DWORD dwAlignSizeSrc; /* source rectangle byte size */ - DWORD dwAlignBoundaryDest; /* dest rectangle alignment */ - DWORD dwAlignSizeDest; /* dest rectangle byte size */ - DWORD dwAlignStrideAlign; /* stride alignment */ - DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */ - DDSCAPS ddsOldCaps; /* old DDSCAPS - superseded for DirectX6+ */ - DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwReserved1; - DWORD dwReserved2; - DWORD dwReserved3; - DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */ - DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */ - DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */ - DWORD dwSVBRops[DD_ROP_SPACE]; /* ROPS supported for System->Vmem blts */ - DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */ - DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */ - DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */ - DWORD dwVSBRops[DD_ROP_SPACE]; /* ROPS supported for Vmem->System blts */ - DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */ - DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */ - DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */ - DWORD dwSSBRops[DD_ROP_SPACE]; /* ROPS supported for System->System blts */ - DWORD dwMaxVideoPorts; /* maximum number of usable video ports */ - DWORD dwCurrVideoPorts; /* current number of video ports used */ - DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */ - DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */ - DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */ - DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */ - DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */ - DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */ - /* and one new member for DirectX 6 */ - DDSCAPS2 ddsCaps; /* surface capabilities */ - } DDCAPS_DX6, *LPDDCAPS_DX6; - - typedef struct _DDCAPS_DX5 { /* DirectX5 version of caps struct */ - DWORD dwSize; /* size of the DDDRIVERCAPS structure */ - DWORD dwCaps; /* driver specific capabilities */ - DWORD dwCaps2; /* more driver specific capabilities */ - DWORD dwCKeyCaps; /* color key capabilities of the surface */ - DWORD dwFXCaps; /* driver specific stretching and effects capabilities */ - DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */ - DWORD dwPalCaps; /* palette capabilities */ - DWORD dwSVCaps; /* stereo vision capabilities */ - DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */ - DWORD dwVidMemTotal; /* total amount of video memory */ - DWORD dwVidMemFree; /* amount of free video memory */ - DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */ - DWORD dwCurrVisibleOverlays; /* current number of visible overlays */ - DWORD dwNumFourCCCodes; /* number of four cc codes */ - DWORD dwAlignBoundarySrc; /* source rectangle alignment */ - DWORD dwAlignSizeSrc; /* source rectangle byte size */ - DWORD dwAlignBoundaryDest; /* dest rectangle alignment */ - DWORD dwAlignSizeDest; /* dest rectangle byte size */ - DWORD dwAlignStrideAlign; /* stride alignment */ - DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */ - DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */ - DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwReserved1; - DWORD dwReserved2; - DWORD dwReserved3; - DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */ - DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */ - DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */ - DWORD dwSVBRops[DD_ROP_SPACE]; /* ROPS supported for System->Vmem blts */ - DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */ - DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */ - DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */ - DWORD dwVSBRops[DD_ROP_SPACE]; /* ROPS supported for Vmem->System blts */ - DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */ - DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */ - DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */ - DWORD dwSSBRops[DD_ROP_SPACE]; /* ROPS supported for System->System blts */ - /* the following are the new DirectX 5 members */ - DWORD dwMaxVideoPorts; /* maximum number of usable video ports */ - DWORD dwCurrVideoPorts; /* current number of video ports used */ - DWORD dwSVBCaps2; /* more driver specific capabilities for System->Vmem blts */ - DWORD dwNLVBCaps; /* driver specific capabilities for non-local->local vidmem blts */ - DWORD dwNLVBCaps2; /* more driver specific capabilities non-local->local vidmem blts */ - DWORD dwNLVBCKeyCaps; /* driver color key capabilities for non-local->local vidmem blts */ - DWORD dwNLVBFXCaps; /* driver FX capabilities for non-local->local blts */ - DWORD dwNLVBRops[DD_ROP_SPACE]; /* ROPS supported for non-local->local blts */ - } DDCAPS_DX5, *LPDDCAPS_DX5; - - typedef struct _DDCAPS_DX3 { /* DirectX3 version of caps struct */ - DWORD dwSize; /* size of the DDDRIVERCAPS structure */ - DWORD dwCaps; /* driver specific capabilities */ - DWORD dwCaps2; /* more driver specific capabilities */ - DWORD dwCKeyCaps; /* color key capabilities of the surface */ - DWORD dwFXCaps; /* driver specific stretching and effects capabilities */ - DWORD dwFXAlphaCaps; /* alpha driver specific capabilities */ - DWORD dwPalCaps; /* palette capabilities */ - DWORD dwSVCaps; /* stereo vision capabilities */ - DWORD dwAlphaBltConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaBltPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaBltSurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlayConstBitDepths; /* DDBD_2,4,8 */ - DWORD dwAlphaOverlayPixelBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwAlphaOverlaySurfaceBitDepths; /* DDBD_1,2,4,8 */ - DWORD dwZBufferBitDepths; /* DDBD_8,16,24,32 */ - DWORD dwVidMemTotal; /* total amount of video memory */ - DWORD dwVidMemFree; /* amount of free video memory */ - DWORD dwMaxVisibleOverlays; /* maximum number of visible overlays */ - DWORD dwCurrVisibleOverlays; /* current number of visible overlays */ - DWORD dwNumFourCCCodes; /* number of four cc codes */ - DWORD dwAlignBoundarySrc; /* source rectangle alignment */ - DWORD dwAlignSizeSrc; /* source rectangle byte size */ - DWORD dwAlignBoundaryDest; /* dest rectangle alignment */ - DWORD dwAlignSizeDest; /* dest rectangle byte size */ - DWORD dwAlignStrideAlign; /* stride alignment */ - DWORD dwRops[DD_ROP_SPACE]; /* ROPS supported */ - DDSCAPS ddsCaps; /* DDSCAPS structure has all the general capabilities */ - DWORD dwMinOverlayStretch; /* minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxOverlayStretch; /* maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinLiveVideoStretch; /* minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxLiveVideoStretch; /* maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMinHwCodecStretch; /* minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwMaxHwCodecStretch; /* maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 */ - DWORD dwReserved1; - DWORD dwReserved2; - DWORD dwReserved3; - DWORD dwSVBCaps; /* driver specific capabilities for System->Vmem blts */ - DWORD dwSVBCKeyCaps; /* driver color key capabilities for System->Vmem blts */ - DWORD dwSVBFXCaps; /* driver FX capabilities for System->Vmem blts */ - DWORD dwSVBRops[DD_ROP_SPACE]; /* ROPS supported for System->Vmem blts */ - DWORD dwVSBCaps; /* driver specific capabilities for Vmem->System blts */ - DWORD dwVSBCKeyCaps; /* driver color key capabilities for Vmem->System blts */ - DWORD dwVSBFXCaps; /* driver FX capabilities for Vmem->System blts */ - DWORD dwVSBRops[DD_ROP_SPACE]; /* ROPS supported for Vmem->System blts */ - DWORD dwSSBCaps; /* driver specific capabilities for System->System blts */ - DWORD dwSSBCKeyCaps; /* driver color key capabilities for System->System blts */ - DWORD dwSSBFXCaps; /* driver FX capabilities for System->System blts */ - DWORD dwSSBRops[DD_ROP_SPACE]; /* ROPS supported for System->System blts */ - DWORD dwReserved4; - DWORD dwReserved5; - DWORD dwReserved6; - } DDCAPS_DX3, *LPDDCAPS_DX3; - -/* set caps struct according to DIRECTDRAW_VERSION */ - -#if DIRECTDRAW_VERSION <= 0x300 - typedef DDCAPS_DX3 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x500 - typedef DDCAPS_DX5 DDCAPS; -#elif DIRECTDRAW_VERSION <= 0x600 - typedef DDCAPS_DX6 DDCAPS; -#else - typedef DDCAPS_DX7 DDCAPS; -#endif - - typedef DDCAPS *LPDDCAPS; - -/* DDCAPS.dwCaps */ -#define DDCAPS_3D 0x00000001 -#define DDCAPS_ALIGNBOUNDARYDEST 0x00000002 -#define DDCAPS_ALIGNSIZEDEST 0x00000004 -#define DDCAPS_ALIGNBOUNDARYSRC 0x00000008 -#define DDCAPS_ALIGNSIZESRC 0x00000010 -#define DDCAPS_ALIGNSTRIDE 0x00000020 -#define DDCAPS_BLT 0x00000040 -#define DDCAPS_BLTQUEUE 0x00000080 -#define DDCAPS_BLTFOURCC 0x00000100 -#define DDCAPS_BLTSTRETCH 0x00000200 -#define DDCAPS_GDI 0x00000400 -#define DDCAPS_OVERLAY 0x00000800 -#define DDCAPS_OVERLAYCANTCLIP 0x00001000 -#define DDCAPS_OVERLAYFOURCC 0x00002000 -#define DDCAPS_OVERLAYSTRETCH 0x00004000 -#define DDCAPS_PALETTE 0x00008000 -#define DDCAPS_PALETTEVSYNC 0x00010000 -#define DDCAPS_READSCANLINE 0x00020000 -#define DDCAPS_STEREOVIEW 0x00040000 -#define DDCAPS_VBI 0x00080000 -#define DDCAPS_ZBLTS 0x00100000 -#define DDCAPS_ZOVERLAYS 0x00200000 -#define DDCAPS_COLORKEY 0x00400000 -#define DDCAPS_ALPHA 0x00800000 -#define DDCAPS_COLORKEYHWASSIST 0x01000000 -#define DDCAPS_NOHARDWARE 0x02000000 -#define DDCAPS_BLTCOLORFILL 0x04000000 -#define DDCAPS_BANKSWITCHED 0x08000000 -#define DDCAPS_BLTDEPTHFILL 0x10000000 -#define DDCAPS_CANCLIP 0x20000000 -#define DDCAPS_CANCLIPSTRETCHED 0x40000000 -#define DDCAPS_CANBLTSYSMEM 0x80000000 - -/* DDCAPS.dwCaps2 */ -#define DDCAPS2_CERTIFIED 0x00000001 -#define DDCAPS2_NO2DDURING3DSCENE 0x00000002 -#define DDCAPS2_VIDEOPORT 0x00000004 -#define DDCAPS2_AUTOFLIPOVERLAY 0x00000008 -#define DDCAPS2_CANBOBINTERLEAVED 0x00000010 -#define DDCAPS2_CANBOBNONINTERLEAVED 0x00000020 -#define DDCAPS2_COLORCONTROLOVERLAY 0x00000040 -#define DDCAPS2_COLORCONTROLPRIMARY 0x00000080 -#define DDCAPS2_CANDROPZ16BIT 0x00000100 -#define DDCAPS2_NONLOCALVIDMEM 0x00000200 -#define DDCAPS2_NONLOCALVIDMEMCAPS 0x00000400 -#define DDCAPS2_NOPAGELOCKREQUIRED 0x00000800 -#define DDCAPS2_WIDESURFACES 0x00001000 -#define DDCAPS2_CANFLIPODDEVEN 0x00002000 -#define DDCAPS2_CANBOBHARDWARE 0x00004000 -#define DDCAPS2_COPYFOURCC 0x00008000 -#define DDCAPS2_PRIMARYGAMMA 0x00020000 -#define DDCAPS2_CANRENDERWINDOWED 0x00080000 -#define DDCAPS2_CANCALIBRATEGAMMA 0x00100000 -#define DDCAPS2_FLIPINTERVAL 0x00200000 -#define DDCAPS2_FLIPNOVSYNC 0x00400000 -#define DDCAPS2_CANMANAGETEXTURE 0x00800000 -#define DDCAPS2_TEXMANINNONLOCALVIDMEM 0x01000000 -#define DDCAPS2_STEREO 0x02000000 -#define DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL 0x04000000 - -/* Set/Get Colour Key Flags */ -#define DDCKEY_COLORSPACE 0x00000001 /* Struct is single colour space */ -#define DDCKEY_DESTBLT 0x00000002 /* To be used as dest for blt */ -#define DDCKEY_DESTOVERLAY 0x00000004 /* To be used as dest for CK overlays */ -#define DDCKEY_SRCBLT 0x00000008 /* To be used as src for blt */ -#define DDCKEY_SRCOVERLAY 0x00000010 /* To be used as src for CK overlays */ - - typedef struct _DDCOLORKEY { - DWORD dwColorSpaceLowValue; /* low boundary of color space that is to - * be treated as Color Key, inclusive - */ - DWORD dwColorSpaceHighValue; /* high boundary of color space that is - * to be treated as Color Key, inclusive - */ - } DDCOLORKEY, *LPDDCOLORKEY; - -/* ddCKEYCAPS bits */ -#define DDCKEYCAPS_DESTBLT 0x00000001 -#define DDCKEYCAPS_DESTBLTCLRSPACE 0x00000002 -#define DDCKEYCAPS_DESTBLTCLRSPACEYUV 0x00000004 -#define DDCKEYCAPS_DESTBLTYUV 0x00000008 -#define DDCKEYCAPS_DESTOVERLAY 0x00000010 -#define DDCKEYCAPS_DESTOVERLAYCLRSPACE 0x00000020 -#define DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV 0x00000040 -#define DDCKEYCAPS_DESTOVERLAYONEACTIVE 0x00000080 -#define DDCKEYCAPS_DESTOVERLAYYUV 0x00000100 -#define DDCKEYCAPS_SRCBLT 0x00000200 -#define DDCKEYCAPS_SRCBLTCLRSPACE 0x00000400 -#define DDCKEYCAPS_SRCBLTCLRSPACEYUV 0x00000800 -#define DDCKEYCAPS_SRCBLTYUV 0x00001000 -#define DDCKEYCAPS_SRCOVERLAY 0x00002000 -#define DDCKEYCAPS_SRCOVERLAYCLRSPACE 0x00004000 -#define DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV 0x00008000 -#define DDCKEYCAPS_SRCOVERLAYONEACTIVE 0x00010000 -#define DDCKEYCAPS_SRCOVERLAYYUV 0x00020000 -#define DDCKEYCAPS_NOCOSTOVERLAY 0x00040000 - - typedef struct _DDPIXELFORMAT { - DWORD dwSize; /* 0: size of structure */ - DWORD dwFlags; /* 4: pixel format flags */ - DWORD dwFourCC; /* 8: (FOURCC code) */ - union { - DWORD dwRGBBitCount; /* C: how many bits per pixel */ - DWORD dwYUVBitCount; /* C: how many bits per pixel */ - DWORD dwZBufferBitDepth; /* C: how many bits for z buffers */ - DWORD dwAlphaBitDepth; /* C: how many bits for alpha channels */ - DWORD dwLuminanceBitCount; - DWORD dwBumpBitCount; - } DUMMYUNIONNAME1; - union { - DWORD dwRBitMask; /* 10: mask for red bit */ - DWORD dwYBitMask; /* 10: mask for Y bits */ - DWORD dwStencilBitDepth; - DWORD dwLuminanceBitMask; - DWORD dwBumpDuBitMask; - } DUMMYUNIONNAME2; - union { - DWORD dwGBitMask; /* 14: mask for green bits */ - DWORD dwUBitMask; /* 14: mask for U bits */ - DWORD dwZBitMask; - DWORD dwBumpDvBitMask; - } DUMMYUNIONNAME3; - union { - DWORD dwBBitMask; /* 18: mask for blue bits */ - DWORD dwVBitMask; /* 18: mask for V bits */ - DWORD dwStencilBitMask; - DWORD dwBumpLuminanceBitMask; - } DUMMYUNIONNAME4; - union { - DWORD dwRGBAlphaBitMask; /* 1C: mask for alpha channel */ - DWORD dwYUVAlphaBitMask; /* 1C: mask for alpha channel */ - DWORD dwLuminanceAlphaBitMask; - DWORD dwRGBZBitMask; /* 1C: mask for Z channel */ - DWORD dwYUVZBitMask; /* 1C: mask for Z channel */ - } DUMMYUNIONNAME5; - /* 20: next structure */ - } DDPIXELFORMAT, *LPDDPIXELFORMAT; - -/* DDCAPS.dwFXCaps */ -#define DDFXCAPS_BLTALPHA 0x00000001 -#define DDFXCAPS_OVERLAYALPHA 0x00000004 -#define DDFXCAPS_BLTARITHSTRETCHYN 0x00000010 -#define DDFXCAPS_BLTARITHSTRETCHY 0x00000020 -#define DDFXCAPS_BLTMIRRORLEFTRIGHT 0x00000040 -#define DDFXCAPS_BLTMIRRORUPDOWN 0x00000080 -#define DDFXCAPS_BLTROTATION 0x00000100 -#define DDFXCAPS_BLTROTATION90 0x00000200 -#define DDFXCAPS_BLTSHRINKX 0x00000400 -#define DDFXCAPS_BLTSHRINKXN 0x00000800 -#define DDFXCAPS_BLTSHRINKY 0x00001000 -#define DDFXCAPS_BLTSHRINKYN 0x00002000 -#define DDFXCAPS_BLTSTRETCHX 0x00004000 -#define DDFXCAPS_BLTSTRETCHXN 0x00008000 -#define DDFXCAPS_BLTSTRETCHY 0x00010000 -#define DDFXCAPS_BLTSTRETCHYN 0x00020000 -#define DDFXCAPS_OVERLAYARITHSTRETCHY 0x00040000 -#define DDFXCAPS_OVERLAYARITHSTRETCHYN 0x00000008 -#define DDFXCAPS_OVERLAYSHRINKX 0x00080000 -#define DDFXCAPS_OVERLAYSHRINKXN 0x00100000 -#define DDFXCAPS_OVERLAYSHRINKY 0x00200000 -#define DDFXCAPS_OVERLAYSHRINKYN 0x00400000 -#define DDFXCAPS_OVERLAYSTRETCHX 0x00800000 -#define DDFXCAPS_OVERLAYSTRETCHXN 0x01000000 -#define DDFXCAPS_OVERLAYSTRETCHY 0x02000000 -#define DDFXCAPS_OVERLAYSTRETCHYN 0x04000000 -#define DDFXCAPS_OVERLAYMIRRORLEFTRIGHT 0x08000000 -#define DDFXCAPS_OVERLAYMIRRORUPDOWN 0x10000000 - -#define DDFXCAPS_OVERLAYFILTER DDFXCAPS_OVERLAYARITHSTRETCHY - -/* DDCAPS.dwFXAlphaCaps */ -#define DDFXALPHACAPS_BLTALPHAEDGEBLEND 0x00000001 -#define DDFXALPHACAPS_BLTALPHAPIXELS 0x00000002 -#define DDFXALPHACAPS_BLTALPHAPIXELSNEG 0x00000004 -#define DDFXALPHACAPS_BLTALPHASURFACES 0x00000008 -#define DDFXALPHACAPS_BLTALPHASURFACESNEG 0x00000010 -#define DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND 0x00000020 -#define DDFXALPHACAPS_OVERLAYALPHAPIXELS 0x00000040 -#define DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG 0x00000080 -#define DDFXALPHACAPS_OVERLAYALPHASURFACES 0x00000100 -#define DDFXALPHACAPS_OVERLAYALPHASURFACESNEG 0x00000200 - -/* DDCAPS.dwPalCaps */ -#define DDPCAPS_4BIT 0x00000001 -#define DDPCAPS_8BITENTRIES 0x00000002 -#define DDPCAPS_8BIT 0x00000004 -#define DDPCAPS_INITIALIZE 0x00000008 -#define DDPCAPS_PRIMARYSURFACE 0x00000010 -#define DDPCAPS_PRIMARYSURFACELEFT 0x00000020 -#define DDPCAPS_ALLOW256 0x00000040 -#define DDPCAPS_VSYNC 0x00000080 -#define DDPCAPS_1BIT 0x00000100 -#define DDPCAPS_2BIT 0x00000200 -#define DDPCAPS_ALPHA 0x00000400 - -/* DDCAPS.dwSVCaps */ -/* the first 4 of these are now obsolete */ -#if DIRECTDRAW_VERSION >= 0x700 /* FIXME: I'm not sure when this switch occurred */ -#define DDSVCAPS_RESERVED1 0x00000001 -#define DDSVCAPS_RESERVED2 0x00000002 -#define DDSVCAPS_RESERVED3 0x00000004 -#define DDSVCAPS_RESERVED4 0x00000008 -#else -#define DDSVCAPS_ENIGMA 0x00000001 -#define DDSVCAPS_FLICKER 0x00000002 -#define DDSVCAPS_REDBLUE 0x00000004 -#define DDSVCAPS_SPLIT 0x00000008 -#endif -#define DDSVCAPS_STEREOSEQUENTIAL 0x00000010 - -/* BitDepths */ -#define DDBD_1 0x00004000 -#define DDBD_2 0x00002000 -#define DDBD_4 0x00001000 -#define DDBD_8 0x00000800 -#define DDBD_16 0x00000400 -#define DDBD_24 0x00000200 -#define DDBD_32 0x00000100 - -/* DDOVERLAYFX.dwDDFX */ -#define DDOVERFX_ARITHSTRETCHY 0x00000001 -#define DDOVERFX_MIRRORLEFTRIGHT 0x00000002 -#define DDOVERFX_MIRRORUPDOWN 0x00000004 - -/* UpdateOverlay flags */ -#define DDOVER_ALPHADEST 0x00000001 -#define DDOVER_ALPHADESTCONSTOVERRIDE 0x00000002 -#define DDOVER_ALPHADESTNEG 0x00000004 -#define DDOVER_ALPHADESTSURFACEOVERRIDE 0x00000008 -#define DDOVER_ALPHAEDGEBLEND 0x00000010 -#define DDOVER_ALPHASRC 0x00000020 -#define DDOVER_ALPHASRCCONSTOVERRIDE 0x00000040 -#define DDOVER_ALPHASRCNEG 0x00000080 -#define DDOVER_ALPHASRCSURFACEOVERRIDE 0x00000100 -#define DDOVER_HIDE 0x00000200 -#define DDOVER_KEYDEST 0x00000400 -#define DDOVER_KEYDESTOVERRIDE 0x00000800 -#define DDOVER_KEYSRC 0x00001000 -#define DDOVER_KEYSRCOVERRIDE 0x00002000 -#define DDOVER_SHOW 0x00004000 -#define DDOVER_ADDDIRTYRECT 0x00008000 -#define DDOVER_REFRESHDIRTYRECTS 0x00010000 -#define DDOVER_REFRESHALL 0x00020000 -#define DDOVER_DDFX 0x00080000 -#define DDOVER_AUTOFLIP 0x00100000 -#define DDOVER_BOB 0x00200000 -#define DDOVER_OVERRIDEBOBWEAVE 0x00400000 -#define DDOVER_INTERLEAVED 0x00800000 - -/* DDCOLORKEY.dwFlags */ -#define DDPF_ALPHAPIXELS 0x00000001 -#define DDPF_ALPHA 0x00000002 -#define DDPF_FOURCC 0x00000004 -#define DDPF_PALETTEINDEXED4 0x00000008 -#define DDPF_PALETTEINDEXEDTO8 0x00000010 -#define DDPF_PALETTEINDEXED8 0x00000020 -#define DDPF_RGB 0x00000040 -#define DDPF_COMPRESSED 0x00000080 -#define DDPF_RGBTOYUV 0x00000100 -#define DDPF_YUV 0x00000200 -#define DDPF_ZBUFFER 0x00000400 -#define DDPF_PALETTEINDEXED1 0x00000800 -#define DDPF_PALETTEINDEXED2 0x00001000 -#define DDPF_ZPIXELS 0x00002000 -#define DDPF_STENCILBUFFER 0x00004000 -#define DDPF_ALPHAPREMULT 0x00008000 -#define DDPF_LUMINANCE 0x00020000 -#define DDPF_BUMPLUMINANCE 0x00040000 -#define DDPF_BUMPDUDV 0x00080000 - -/* SetCooperativeLevel dwFlags */ -#define DDSCL_FULLSCREEN 0x00000001 -#define DDSCL_ALLOWREBOOT 0x00000002 -#define DDSCL_NOWINDOWCHANGES 0x00000004 -#define DDSCL_NORMAL 0x00000008 -#define DDSCL_EXCLUSIVE 0x00000010 -#define DDSCL_ALLOWMODEX 0x00000040 -#define DDSCL_SETFOCUSWINDOW 0x00000080 -#define DDSCL_SETDEVICEWINDOW 0x00000100 -#define DDSCL_CREATEDEVICEWINDOW 0x00000200 -#define DDSCL_MULTITHREADED 0x00000400 -#define DDSCL_FPUSETUP 0x00000800 -#define DDSCL_FPUPRESERVE 0x00001000 - -/* DDSURFACEDESC.dwFlags */ -#define DDSD_CAPS 0x00000001 -#define DDSD_HEIGHT 0x00000002 -#define DDSD_WIDTH 0x00000004 -#define DDSD_PITCH 0x00000008 -#define DDSD_BACKBUFFERCOUNT 0x00000020 -#define DDSD_ZBUFFERBITDEPTH 0x00000040 -#define DDSD_ALPHABITDEPTH 0x00000080 -#define DDSD_LPSURFACE 0x00000800 -#define DDSD_PIXELFORMAT 0x00001000 -#define DDSD_CKDESTOVERLAY 0x00002000 -#define DDSD_CKDESTBLT 0x00004000 -#define DDSD_CKSRCOVERLAY 0x00008000 -#define DDSD_CKSRCBLT 0x00010000 -#define DDSD_MIPMAPCOUNT 0x00020000 -#define DDSD_REFRESHRATE 0x00040000 -#define DDSD_LINEARSIZE 0x00080000 -#define DDSD_TEXTURESTAGE 0x00100000 -#define DDSD_FVF 0x00200000 -#define DDSD_SRCVBHANDLE 0x00400000 -#define DDSD_ALL 0x007ff9ee - -/* EnumSurfaces flags */ -#define DDENUMSURFACES_ALL 0x00000001 -#define DDENUMSURFACES_MATCH 0x00000002 -#define DDENUMSURFACES_NOMATCH 0x00000004 -#define DDENUMSURFACES_CANBECREATED 0x00000008 -#define DDENUMSURFACES_DOESEXIST 0x00000010 - -/* SetDisplayMode flags */ -#define DDSDM_STANDARDVGAMODE 0x00000001 - -/* EnumDisplayModes flags */ -#define DDEDM_REFRESHRATES 0x00000001 -#define DDEDM_STANDARDVGAMODES 0x00000002 - -/* WaitForVerticalDisplay flags */ - -#define DDWAITVB_BLOCKBEGIN 0x00000001 -#define DDWAITVB_BLOCKBEGINEVENT 0x00000002 -#define DDWAITVB_BLOCKEND 0x00000004 - - typedef struct _DDSURFACEDESC { - DWORD dwSize; /* 0: size of the DDSURFACEDESC structure */ - DWORD dwFlags; /* 4: determines what fields are valid */ - DWORD dwHeight; /* 8: height of surface to be created */ - DWORD dwWidth; /* C: width of input surface */ - union { - LONG lPitch; /* 10: distance to start of next line (return value only) */ - DWORD dwLinearSize; - } DUMMYUNIONNAME1; - DWORD dwBackBufferCount; /* 14: number of back buffers requested */ - union { - DWORD dwMipMapCount; /* 18:number of mip-map levels requested */ - DWORD dwZBufferBitDepth; /*18: depth of Z buffer requested */ - DWORD dwRefreshRate; /* 18:refresh rate (used when display mode is described) */ - } DUMMYUNIONNAME2; - DWORD dwAlphaBitDepth; /* 1C:depth of alpha buffer requested */ - DWORD dwReserved; /* 20:reserved */ - LPVOID lpSurface; /* 24:pointer to the associated surface memory */ - DDCOLORKEY ddckCKDestOverlay; /* 28: CK for dest overlay use */ - DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use */ - DDCOLORKEY ddckCKSrcOverlay; /* 38: CK for source overlay use */ - DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use */ - DDPIXELFORMAT ddpfPixelFormat; /* 48: pixel format description of the surface */ - DDSCAPS ddsCaps; /* 68: direct draw surface caps */ - } DDSURFACEDESC, *LPDDSURFACEDESC; - - typedef struct _DDSURFACEDESC2 { - DWORD dwSize; /* 0: size of the DDSURFACEDESC structure */ - DWORD dwFlags; /* 4: determines what fields are valid */ - DWORD dwHeight; /* 8: height of surface to be created */ - DWORD dwWidth; /* C: width of input surface */ - union { - LONG lPitch; /*10: distance to start of next line (return value only) */ - DWORD dwLinearSize; /*10: formless late-allocated optimized surface size */ - } DUMMYUNIONNAME1; - DWORD dwBackBufferCount; /* 14: number of back buffers requested */ - union { - DWORD dwMipMapCount; /* 18:number of mip-map levels requested */ - DWORD dwRefreshRate; /* 18:refresh rate (used when display mode is described) */ - DWORD dwSrcVBHandle; /* 18:source used in VB::Optimize */ - } DUMMYUNIONNAME2; - DWORD dwAlphaBitDepth; /* 1C:depth of alpha buffer requested */ - DWORD dwReserved; /* 20:reserved */ - LPVOID lpSurface; /* 24:pointer to the associated surface memory */ - union { - DDCOLORKEY ddckCKDestOverlay; /* 28: CK for dest overlay use */ - DWORD dwEmptyFaceColor; /* 28: color for empty cubemap faces */ - } DUMMYUNIONNAME3; - DDCOLORKEY ddckCKDestBlt; /* 30: CK for destination blt use */ - DDCOLORKEY ddckCKSrcOverlay; /* 38: CK for source overlay use */ - DDCOLORKEY ddckCKSrcBlt; /* 40: CK for source blt use */ - - union { - DDPIXELFORMAT ddpfPixelFormat; /* 48: pixel format description of the surface */ - DWORD dwFVF; /* 48: vertex format description of vertex buffers */ - } DUMMYUNIONNAME4; - DDSCAPS2 ddsCaps; /* 68: DDraw surface caps */ - DWORD dwTextureStage; /* 78: stage in multitexture cascade */ - } DDSURFACEDESC2, *LPDDSURFACEDESC2; - -/* DDCOLORCONTROL.dwFlags */ -#define DDCOLOR_BRIGHTNESS 0x00000001 -#define DDCOLOR_CONTRAST 0x00000002 -#define DDCOLOR_HUE 0x00000004 -#define DDCOLOR_SATURATION 0x00000008 -#define DDCOLOR_SHARPNESS 0x00000010 -#define DDCOLOR_GAMMA 0x00000020 -#define DDCOLOR_COLORENABLE 0x00000040 - - typedef struct { - DWORD dwSize; - DWORD dwFlags; - LONG lBrightness; - LONG lContrast; - LONG lHue; - LONG lSaturation; - LONG lSharpness; - LONG lGamma; - LONG lColorEnable; - DWORD dwReserved1; - } DDCOLORCONTROL, *LPDDCOLORCONTROL; - - typedef struct { - WORD red[256]; - WORD green[256]; - WORD blue[256]; - } DDGAMMARAMP, *LPDDGAMMARAMP; - - typedef BOOL CALLBACK(*LPDDENUMCALLBACKA) (GUID *, LPSTR, LPSTR, LPVOID); - typedef BOOL CALLBACK(*LPDDENUMCALLBACKW) (GUID *, LPWSTR, LPWSTR, LPVOID); - DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACK) - - typedef HRESULT CALLBACK(*LPDDENUMMODESCALLBACK) (LPDDSURFACEDESC, LPVOID); - typedef HRESULT CALLBACK(*LPDDENUMMODESCALLBACK2) (LPDDSURFACEDESC2, - LPVOID); - typedef HRESULT CALLBACK(*LPDDENUMSURFACESCALLBACK) (LPDIRECTDRAWSURFACE, - LPDDSURFACEDESC, - LPVOID); - typedef HRESULT CALLBACK(*LPDDENUMSURFACESCALLBACK2) (LPDIRECTDRAWSURFACE4, - LPDDSURFACEDESC2, - LPVOID); - typedef HRESULT CALLBACK(*LPDDENUMSURFACESCALLBACK7) (LPDIRECTDRAWSURFACE7, - LPDDSURFACEDESC2, - LPVOID); - - typedef BOOL CALLBACK(*LPDDENUMCALLBACKEXA) (GUID *, LPSTR, LPSTR, LPVOID, - HMONITOR); - typedef BOOL CALLBACK(*LPDDENUMCALLBACKEXW) (GUID *, LPWSTR, LPWSTR, LPVOID, - HMONITOR); - DECL_WINELIB_TYPE_AW(LPDDENUMCALLBACKEX) - - HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, - LPVOID lpContext, DWORD dwFlags); - HRESULT WINAPI DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback, - LPVOID lpContext, DWORD dwFlags); -#define DirectDrawEnumerateEx WINELIB_NAME_AW(DirectDrawEnumerateEx) - -/* flags for DirectDrawEnumerateEx */ -#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001 -#define DDENUM_DETACHEDSECONDARYDEVICES 0x00000002 -#define DDENUM_NONDISPLAYDEVICES 0x00000004 - -/* flags for DirectDrawCreate or IDirectDraw::Initialize */ -#define DDCREATE_HARDWAREONLY 1L -#define DDCREATE_EMULATIONONLY 2L - - typedef struct _DDBLTFX { - DWORD dwSize; /* size of structure */ - DWORD dwDDFX; /* FX operations */ - DWORD dwROP; /* Win32 raster operations */ - DWORD dwDDROP; /* Raster operations new for DirectDraw */ - DWORD dwRotationAngle; /* Rotation angle for blt */ - DWORD dwZBufferOpCode; /* ZBuffer compares */ - DWORD dwZBufferLow; /* Low limit of Z buffer */ - DWORD dwZBufferHigh; /* High limit of Z buffer */ - DWORD dwZBufferBaseDest; /* Destination base value */ - DWORD dwZDestConstBitDepth; /* Bit depth used to specify Z constant for destination */ - union { - DWORD dwZDestConst; /* Constant to use as Z buffer for dest */ - LPDIRECTDRAWSURFACE lpDDSZBufferDest; /* Surface to use as Z buffer for dest */ - } DUMMYUNIONNAME1; - DWORD dwZSrcConstBitDepth; /* Bit depth used to specify Z constant for source */ - union { - DWORD dwZSrcConst; /* Constant to use as Z buffer for src */ - LPDIRECTDRAWSURFACE lpDDSZBufferSrc; /* Surface to use as Z buffer for src */ - } DUMMYUNIONNAME2; - DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */ - DWORD dwAlphaEdgeBlend; /* Alpha for edge blending */ - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */ - union { - DWORD dwAlphaDestConst; /* Constant to use as Alpha Channel */ - LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as Alpha Channel */ - } DUMMYUNIONNAME3; - DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */ - union { - DWORD dwAlphaSrcConst; /* Constant to use as Alpha Channel */ - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as Alpha Channel */ - } DUMMYUNIONNAME4; - union { - DWORD dwFillColor; /* color in RGB or Palettized */ - DWORD dwFillDepth; /* depth value for z-buffer */ - DWORD dwFillPixel; /* pixel val for RGBA or RGBZ */ - LPDIRECTDRAWSURFACE lpDDSPattern; /* Surface to use as pattern */ - } DUMMYUNIONNAME5; - DDCOLORKEY ddckDestColorkey; /* DestColorkey override */ - DDCOLORKEY ddckSrcColorkey; /* SrcColorkey override */ - } DDBLTFX, *LPDDBLTFX; - -/* dwDDFX */ -/* arithmetic stretching along y axis */ -#define DDBLTFX_ARITHSTRETCHY 0x00000001 -/* mirror on y axis */ -#define DDBLTFX_MIRRORLEFTRIGHT 0x00000002 -/* mirror on x axis */ -#define DDBLTFX_MIRRORUPDOWN 0x00000004 -/* do not tear */ -#define DDBLTFX_NOTEARING 0x00000008 -/* 180 degrees clockwise rotation */ -#define DDBLTFX_ROTATE180 0x00000010 -/* 270 degrees clockwise rotation */ -#define DDBLTFX_ROTATE270 0x00000020 -/* 90 degrees clockwise rotation */ -#define DDBLTFX_ROTATE90 0x00000040 -/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */ -#define DDBLTFX_ZBUFFERRANGE 0x00000080 -/* add dwZBufferBaseDest to every source z value before compare */ -#define DDBLTFX_ZBUFFERBASEDEST 0x00000100 - - typedef struct _DDOVERLAYFX { - DWORD dwSize; /* size of structure */ - DWORD dwAlphaEdgeBlendBitDepth; /* Bit depth used to specify constant for alpha edge blend */ - DWORD dwAlphaEdgeBlend; /* Constant to use as alpha for edge blend */ - DWORD dwReserved; - DWORD dwAlphaDestConstBitDepth; /* Bit depth used to specify alpha constant for destination */ - union { - DWORD dwAlphaDestConst; /* Constant to use as alpha channel for dest */ - LPDIRECTDRAWSURFACE lpDDSAlphaDest; /* Surface to use as alpha channel for dest */ - } DUMMYUNIONNAME1; - DWORD dwAlphaSrcConstBitDepth; /* Bit depth used to specify alpha constant for source */ - union { - DWORD dwAlphaSrcConst; /* Constant to use as alpha channel for src */ - LPDIRECTDRAWSURFACE lpDDSAlphaSrc; /* Surface to use as alpha channel for src */ - } DUMMYUNIONNAME2; - DDCOLORKEY dckDestColorkey; /* DestColorkey override */ - DDCOLORKEY dckSrcColorkey; /* DestColorkey override */ - DWORD dwDDFX; /* Overlay FX */ - DWORD dwFlags; /* flags */ - } DDOVERLAYFX, *LPDDOVERLAYFX; - - typedef struct _DDBLTBATCH { - LPRECT lprDest; - LPDIRECTDRAWSURFACE lpDDSSrc; - LPRECT lprSrc; - DWORD dwFlags; - LPDDBLTFX lpDDBltFx; - } DDBLTBATCH, *LPDDBLTBATCH; - -#define MAX_DDDEVICEID_STRING 512 - - typedef struct tagDDDEVICEIDENTIFIER { - char szDriver[MAX_DDDEVICEID_STRING]; - char szDescription[MAX_DDDEVICEID_STRING]; - LARGE_INTEGER liDriverVersion; - DWORD dwVendorId; - DWORD dwDeviceId; - DWORD dwSubSysId; - DWORD dwRevision; - GUID guidDeviceIdentifier; - } DDDEVICEIDENTIFIER, *LPDDDEVICEIDENTIFIER; - - typedef struct tagDDDEVICEIDENTIFIER2 { - char szDriver[MAX_DDDEVICEID_STRING]; /* user readable driver name */ - char szDescription[MAX_DDDEVICEID_STRING]; /* user readable description */ - LARGE_INTEGER liDriverVersion; /* driver version */ - DWORD dwVendorId; /* vendor ID, zero if unknown */ - DWORD dwDeviceId; /* chipset ID, zero if unknown */ - DWORD dwSubSysId; /* board ID, zero if unknown */ - DWORD dwRevision; /* chipset version, zero if unknown */ - GUID guidDeviceIdentifier; /* unique ID for this driver/chipset combination */ - DWORD dwWHQLLevel; /* Windows Hardware Quality Lab certification level */ - } DDDEVICEIDENTIFIER2, *LPDDDEVICEIDENTIFIER2; - -/***************************************************************************** - * IDirectDrawPalette interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawPalette - DECLARE_INTERFACE_(IDirectDrawPalette, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, PVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDWORD lpdwCaps) PURE; - STDMETHOD(GetEntries) (THIS_ DWORD dwFlags, DWORD dwBase, - DWORD dwNumEntries, - LPPALETTEENTRY lpEntries) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags, - LPPALETTEENTRY lpDDColorTable) PURE; - STDMETHOD(SetEntries) (THIS_ DWORD dwFlags, DWORD dwStartingEntry, - DWORD dwCount, LPPALETTEENTRY lpEntries) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawPalette_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawPalette_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawPalette_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDrawPalette methods ***/ -#define IDirectDrawPalette_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawPalette_GetEntries(p,a,b,c,d) ICOM_CALL_(GetEntries,p,(p,a,b,c,d)) -#define IDirectDrawPalette_Initialize(p,a,b,c) ICOM_CALL_(Initialize,p,(p,a,b,c)) -#define IDirectDrawPalette_SetEntries(p,a,b,c,d) ICOM_CALL_(SetEntries,p,(p,a,b,c,d)) - -/***************************************************************************** - * IDirectDrawClipper interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawClipper - DECLARE_INTERFACE_(IDirectDrawClipper, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(GetClipList) (THIS_ LPRECT lpRect, LPRGNDATA lpClipList, - LPDWORD lpdwSize) PURE; - STDMETHOD(GetHWnd) (THIS_ HWND * lphWnd) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, DWORD dwFlags) PURE; - STDMETHOD(IsClipListChanged) (THIS_ BOOL * lpbChanged) PURE; - STDMETHOD(SetClipList) (THIS_ LPRGNDATA lpClipList, DWORD dwFlags) PURE; - STDMETHOD(SetHWnd) (THIS_ DWORD dwFlags, HWND hWnd) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawClipper_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawClipper_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawClipper_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDrawClipper methods ***/ -#define IDirectDrawClipper_GetClipList(p,a,b,c) ICOM_CALL_(GetClipList,p,(p,a,b,c)) -#define IDirectDrawClipper_GetHWnd(p,a) ICOM_CALL_(GetHWnd,p,(p,a)) -#define IDirectDrawClipper_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawClipper_IsClipListChanged(p,a) ICOM_CALL_(IsClipListChanged,p,(p,a)) -#define IDirectDrawClipper_SetClipList(p,a,b) ICOM_CALL_(SetClipList,p,(p,a,b)) -#define IDirectDrawClipper_SetHWnd(p,a,b) ICOM_CALL_(SetHWnd,p,(p,a,b)) - -/***************************************************************************** - * IDirectDraw interface - */ -#undef INTERFACE -#define INTERFACE IDirectDraw - DECLARE_INTERFACE_(IDirectDraw, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(CreateClipper) (THIS_ DWORD dwFlags, - LPDIRECTDRAWCLIPPER * lplpDDClipper, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreatePalette) (THIS_ DWORD dwFlags, - LPPALETTEENTRY lpColorTable, - LPDIRECTDRAWPALETTE * lplpDDPalette, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreateSurface) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, - LPDIRECTDRAWSURFACE * lplpDDSurface, - IUnknown * pUnkOuter) PURE; - STDMETHOD(DuplicateSurface) (THIS_ LPDIRECTDRAWSURFACE lpDDSurface, - LPDIRECTDRAWSURFACE * - lplpDupDDSurface) PURE; - STDMETHOD(EnumDisplayModes) (THIS_ DWORD dwFlags, - LPDDSURFACEDESC lpDDSurfaceDesc, - LPVOID lpContext, - LPDDENUMMODESCALLBACK lpEnumModesCallback) - PURE; - STDMETHOD(EnumSurfaces) (THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, - LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(FlipToGDISurface) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDCAPS lpDDDriverCaps, - LPDDCAPS lpDDHELCaps) PURE; - STDMETHOD(GetDisplayMode) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(GetFourCCCodes) (THIS_ LPDWORD lpNumCodes, - LPDWORD lpCodes) PURE; - STDMETHOD(GetGDISurface) (THIS_ LPDIRECTDRAWSURFACE * - lplpGDIDDSurface) PURE; - STDMETHOD(GetMonitorFrequency) (THIS_ LPDWORD lpdwFrequency) PURE; - STDMETHOD(GetScanLine) (THIS_ LPDWORD lpdwScanLine) PURE; - STDMETHOD(GetVerticalBlankStatus) (THIS_ BOOL * lpbIsInVB) PURE; - STDMETHOD(Initialize) (THIS_ GUID * lpGUID) PURE; - STDMETHOD(RestoreDisplayMode) (THIS) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hWnd, DWORD dwFlags) PURE; - STDMETHOD(SetDisplayMode) (THIS_ DWORD, DWORD, DWORD) PURE; - STDMETHOD(WaitForVerticalBlank) (THIS_ DWORD dwFlags, - HANDLE hEvent) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDraw_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDraw_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDraw_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDraw methods ***/ -#define IDirectDraw_Compact(p) ICOM_CALL_(Compact,p,(p)) -#define IDirectDraw_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c)) -#define IDirectDraw_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d)) -#define IDirectDraw_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c)) -#define IDirectDraw_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b)) -#define IDirectDraw_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d)) -#define IDirectDraw_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d)) -#define IDirectDraw_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p)) -#define IDirectDraw_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b)) -#define IDirectDraw_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a)) -#define IDirectDraw_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b)) -#define IDirectDraw_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a)) -#define IDirectDraw_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a)) -#define IDirectDraw_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a)) -#define IDirectDraw_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a)) -#define IDirectDraw_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a)) -#define IDirectDraw_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p)) -#define IDirectDraw_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b)) -#define IDirectDraw_SetDisplayMode(p,a,b,c) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c)) -#define IDirectDraw_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b)) - -/* flags for Lock() */ -#define DDLOCK_SURFACEMEMORYPTR 0x00000000 -#define DDLOCK_WAIT 0x00000001 -#define DDLOCK_EVENT 0x00000002 -#define DDLOCK_READONLY 0x00000010 -#define DDLOCK_WRITEONLY 0x00000020 -#define DDLOCK_NOSYSLOCK 0x00000800 - -/***************************************************************************** - * IDirectDraw2 interface - */ -/* Note: IDirectDraw2 cannot derive from IDirectDraw because the number of - * arguments of SetDisplayMode has changed ! - */ -#undef INTERFACE -#define INTERFACE IDirectDraw2 - DECLARE_INTERFACE_(IDirectDraw2, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(CreateClipper) (THIS_ DWORD dwFlags, - LPDIRECTDRAWCLIPPER * lplpDDClipper, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreatePalette) (THIS_ DWORD dwFlags, - LPPALETTEENTRY lpColorTable, - LPDIRECTDRAWPALETTE * lplpDDPalette, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreateSurface) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc, - LPDIRECTDRAWSURFACE2 * lplpDDSurface, - IUnknown * pUnkOuter) PURE; - STDMETHOD(DuplicateSurface) (THIS_ LPDIRECTDRAWSURFACE2 lpDDSurface, - LPDIRECTDRAWSURFACE2 * - lplpDupDDSurface) PURE; - STDMETHOD(EnumDisplayModes) (THIS_ DWORD dwFlags, - LPDDSURFACEDESC lpDDSurfaceDesc, - LPVOID lpContext, - LPDDENUMMODESCALLBACK lpEnumModesCallback) - PURE; - STDMETHOD(EnumSurfaces) (THIS_ DWORD dwFlags, LPDDSURFACEDESC lpDDSD, - LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(FlipToGDISurface) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDCAPS lpDDDriverCaps, - LPDDCAPS lpDDHELCaps) PURE; - STDMETHOD(GetDisplayMode) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(GetFourCCCodes) (THIS_ LPDWORD lpNumCodes, - LPDWORD lpCodes) PURE; - STDMETHOD(GetGDISurface) (THIS_ LPDIRECTDRAWSURFACE2 * - lplpGDIDDSurface) PURE; - STDMETHOD(GetMonitorFrequency) (THIS_ LPDWORD lpdwFrequency) PURE; - STDMETHOD(GetScanLine) (THIS_ LPDWORD lpdwScanLine) PURE; - STDMETHOD(GetVerticalBlankStatus) (THIS_ BOOL * lpbIsInVB) PURE; - STDMETHOD(Initialize) (THIS_ GUID * lpGUID) PURE; - STDMETHOD(RestoreDisplayMode) (THIS) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hWnd, DWORD dwFlags) PURE; - STDMETHOD(SetDisplayMode) (THIS_ DWORD dwWidth, DWORD dwHeight, - DWORD dwBPP, DWORD dwRefreshRate, - DWORD dwFlags) PURE; - STDMETHOD(WaitForVerticalBlank) (THIS_ DWORD dwFlags, - HANDLE hEvent) PURE; - - STDMETHOD(GetAvailableVidMem) (THIS_ LPDDSCAPS lpDDCaps, - LPDWORD lpdwTotal, - LPDWORD lpdwFree) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDraw2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDraw2_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDraw2_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDraw methods ***/ -#define IDirectDraw2_Compact(p) ICOM_CALL_(Compact,p,(p)) -#define IDirectDraw2_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c)) -#define IDirectDraw2_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d)) -#define IDirectDraw2_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c)) -#define IDirectDraw2_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b)) -#define IDirectDraw2_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d)) -#define IDirectDraw2_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d)) -#define IDirectDraw2_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p)) -#define IDirectDraw2_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b)) -#define IDirectDraw2_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a)) -#define IDirectDraw2_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b)) -#define IDirectDraw2_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a)) -#define IDirectDraw2_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a)) -#define IDirectDraw2_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a)) -#define IDirectDraw2_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a)) -#define IDirectDraw2_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a)) -#define IDirectDraw2_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p)) -#define IDirectDraw2_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b)) -#define IDirectDraw2_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e)) -#define IDirectDraw2_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b)) -/*** IDirectDraw2 methods ***/ -#define IDirectDraw2_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c)) - -/***************************************************************************** - * IDirectDraw4 interface - */ -#undef INTERFACE -#define INTERFACE IDirectDraw4 - DECLARE_INTERFACE_(IDirectDraw4, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(CreateClipper) (THIS_ DWORD dwFlags, - LPDIRECTDRAWCLIPPER * lplpDDClipper, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreatePalette) (THIS_ DWORD dwFlags, - LPPALETTEENTRY lpColorTable, - LPDIRECTDRAWPALETTE * lplpDDPalette, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreateSurface) (THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, - LPDIRECTDRAWSURFACE4 * lplpDDSurface, - IUnknown * pUnkOuter) PURE; - STDMETHOD(DuplicateSurface) (THIS_ LPDIRECTDRAWSURFACE4 lpDDSurface, - LPDIRECTDRAWSURFACE4 * - lplpDupDDSurface) PURE; - STDMETHOD(EnumDisplayModes) (THIS_ DWORD dwFlags, - LPDDSURFACEDESC2 lpDDSurfaceDesc, - LPVOID lpContext, - LPDDENUMMODESCALLBACK2 lpEnumModesCallback) - PURE; - STDMETHOD(EnumSurfaces) (THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, - LPVOID lpContext, - LPDDENUMSURFACESCALLBACK2 - lpEnumSurfacesCallback) PURE; - STDMETHOD(FlipToGDISurface) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDCAPS lpDDDriverCaps, - LPDDCAPS lpDDHELCaps) PURE; - STDMETHOD(GetDisplayMode) (THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE; - STDMETHOD(GetFourCCCodes) (THIS_ LPDWORD lpNumCodes, - LPDWORD lpCodes) PURE; - STDMETHOD(GetGDISurface) (THIS_ LPDIRECTDRAWSURFACE4 * - lplpGDIDDSurface) PURE; - STDMETHOD(GetMonitorFrequency) (THIS_ LPDWORD lpdwFrequency) PURE; - STDMETHOD(GetScanLine) (THIS_ LPDWORD lpdwScanLine) PURE; - STDMETHOD(GetVerticalBlankStatus) (THIS_ BOOL * lpbIsInVB) PURE; - STDMETHOD(Initialize) (THIS_ GUID * lpGUID) PURE; - STDMETHOD(RestoreDisplayMode) (THIS) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hWnd, DWORD dwFlags) PURE; - STDMETHOD(SetDisplayMode) (THIS_ DWORD dwWidth, DWORD dwHeight, - DWORD dwBPP, DWORD dwRefreshRate, - DWORD dwFlags) PURE; - STDMETHOD(WaitForVerticalBlank) (THIS_ DWORD dwFlags, - HANDLE hEvent) PURE; - - STDMETHOD(GetAvailableVidMem) (THIS_ LPDDSCAPS2 lpDDCaps, - LPDWORD lpdwTotal, - LPDWORD lpdwFree) PURE; - - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE4 *) PURE; - STDMETHOD(RestoreAllSurfaces) (THIS) PURE; - STDMETHOD(TestCooperativeLevel) (THIS) PURE; - STDMETHOD(GetDeviceIdentifier) (THIS_ LPDDDEVICEIDENTIFIER, DWORD) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDraw4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDraw4_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDraw4_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDraw methods ***/ -#define IDirectDraw4_Compact(p) ICOM_CALL_(Compact,p,(p)) -#define IDirectDraw4_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c)) -#define IDirectDraw4_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d)) -#define IDirectDraw4_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c)) -#define IDirectDraw4_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b)) -#define IDirectDraw4_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d)) -#define IDirectDraw4_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d)) -#define IDirectDraw4_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p)) -#define IDirectDraw4_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b)) -#define IDirectDraw4_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a)) -#define IDirectDraw4_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b)) -#define IDirectDraw4_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a)) -#define IDirectDraw4_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a)) -#define IDirectDraw4_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a)) -#define IDirectDraw4_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a)) -#define IDirectDraw4_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a)) -#define IDirectDraw4_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p)) -#define IDirectDraw4_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b)) -#define IDirectDraw4_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e)) -#define IDirectDraw4_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b)) -/*** IDirectDraw2 methods ***/ -#define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c)) -/*** IDirectDraw4 methods ***/ -#define IDirectDraw4_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b)) -#define IDirectDraw4_RestoreAllSurfaces(p) ICOM_CALL_(RestoreAllSurfaces,p,(p)) -#define IDirectDraw4_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p)) -#define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b)) - -/***************************************************************************** - * IDirectDraw7 interface - */ -/* Note: IDirectDraw7 cannot derive from IDirectDraw4; it is even documented - * as not interchangeable with earlier DirectDraw interfaces. - */ -#undef INTERFACE -#define INTERFACE IDirectDraw7 - DECLARE_INTERFACE_(IDirectDraw7, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(Compact) (THIS) PURE; - STDMETHOD(CreateClipper) (THIS_ DWORD dwFlags, - LPDIRECTDRAWCLIPPER * lplpDDClipper, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreatePalette) (THIS_ DWORD dwFlags, - LPPALETTEENTRY lpColorTable, - LPDIRECTDRAWPALETTE * lplpDDPalette, - IUnknown * pUnkOuter) PURE; - STDMETHOD(CreateSurface) (THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc, - LPDIRECTDRAWSURFACE7 * lplpDDSurface, - IUnknown * pUnkOuter) PURE; - STDMETHOD(DuplicateSurface) (THIS_ LPDIRECTDRAWSURFACE7 lpDDSurface, - LPDIRECTDRAWSURFACE7 * - lplpDupDDSurface) PURE; - STDMETHOD(EnumDisplayModes) (THIS_ DWORD dwFlags, - LPDDSURFACEDESC2 lpDDSurfaceDesc, - LPVOID lpContext, - LPDDENUMMODESCALLBACK2 lpEnumModesCallback) - PURE; - STDMETHOD(EnumSurfaces) (THIS_ DWORD dwFlags, LPDDSURFACEDESC2 lpDDSD, - LPVOID lpContext, - LPDDENUMSURFACESCALLBACK7 - lpEnumSurfacesCallback) PURE; - STDMETHOD(FlipToGDISurface) (THIS) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDCAPS lpDDDriverCaps, - LPDDCAPS lpDDHELCaps) PURE; - STDMETHOD(GetDisplayMode) (THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE; - STDMETHOD(GetFourCCCodes) (THIS_ LPDWORD lpNumCodes, - LPDWORD lpCodes) PURE; - STDMETHOD(GetGDISurface) (THIS_ LPDIRECTDRAWSURFACE7 * - lplpGDIDDSurface) PURE; - STDMETHOD(GetMonitorFrequency) (THIS_ LPDWORD lpdwFrequency) PURE; - STDMETHOD(GetScanLine) (THIS_ LPDWORD lpdwScanLine) PURE; - STDMETHOD(GetVerticalBlankStatus) (THIS_ BOOL * lpbIsInVB) PURE; - STDMETHOD(Initialize) (THIS_ GUID * lpGUID) PURE; - STDMETHOD(RestoreDisplayMode) (THIS) PURE; - STDMETHOD(SetCooperativeLevel) (THIS_ HWND hWnd, DWORD dwFlags) PURE; - STDMETHOD(SetDisplayMode) (THIS_ DWORD dwWidth, DWORD dwHeight, - DWORD dwBPP, DWORD dwRefreshRate, - DWORD dwFlags) PURE; - STDMETHOD(WaitForVerticalBlank) (THIS_ DWORD dwFlags, - HANDLE hEvent) PURE; - - STDMETHOD(GetAvailableVidMem) (THIS_ LPDDSCAPS2 lpDDCaps, - LPDWORD lpdwTotal, - LPDWORD lpdwFree) PURE; - - STDMETHOD(GetSurfaceFromDC) (THIS_ HDC, LPDIRECTDRAWSURFACE7 *) PURE; - STDMETHOD(RestoreAllSurfaces) (THIS) PURE; - STDMETHOD(TestCooperativeLevel) (THIS) PURE; - STDMETHOD(GetDeviceIdentifier) (THIS_ LPDDDEVICEIDENTIFIER2, - DWORD) PURE; - - STDMETHOD(StartModeTest) (THIS_ LPSIZE, DWORD, DWORD) PURE; - STDMETHOD(EvaluateMode) (THIS_ DWORD, DWORD *) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDraw7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDraw7_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDraw7_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDraw methods ***/ -#define IDirectDraw7_Compact(p) ICOM_CALL_(Compact,p,(p)) -#define IDirectDraw7_CreateClipper(p,a,b,c) ICOM_CALL_(CreateClipper,p,(p,a,b,c)) -#define IDirectDraw7_CreatePalette(p,a,b,c,d) ICOM_CALL_(CreatePalette,p,(p,a,b,c,d)) -#define IDirectDraw7_CreateSurface(p,a,b,c) ICOM_CALL_(CreateSurface,p,(p,a,b,c)) -#define IDirectDraw7_DuplicateSurface(p,a,b) ICOM_CALL_(DuplicateSurface,p,(p,a,b)) -#define IDirectDraw7_EnumDisplayModes(p,a,b,c,d) ICOM_CALL_(EnumDisplayModes,p,(p,a,b,c,d)) -#define IDirectDraw7_EnumSurfaces(p,a,b,c,d) ICOM_CALL_(EnumSurfaces,p,(p,a,b,c,d)) -#define IDirectDraw7_FlipToGDISurface(p) ICOM_CALL_(FlipToGDISurface,p,(p)) -#define IDirectDraw7_GetCaps(p,a,b) ICOM_CALL_(GetCaps,p,(p,a,b)) -#define IDirectDraw7_GetDisplayMode(p,a) ICOM_CALL_(GetDisplayMode,p,(p,a)) -#define IDirectDraw7_GetFourCCCodes(p,a,b) ICOM_CALL_(GetFourCCCodes,p,(p,a,b)) -#define IDirectDraw7_GetGDISurface(p,a) ICOM_CALL_(GetGDISurface,p,(p,a)) -#define IDirectDraw7_GetMonitorFrequency(p,a) ICOM_CALL_(GetMonitorFrequency,p,(p,a)) -#define IDirectDraw7_GetScanLine(p,a) ICOM_CALL_(GetScanLine,p,(p,a)) -#define IDirectDraw7_GetVerticalBlankStatus(p,a) ICOM_CALL_(GetVerticalBlankStatus,p,(p,a)) -#define IDirectDraw7_Initialize(p,a) ICOM_CALL_(Initialize,p,(p,a)) -#define IDirectDraw7_RestoreDisplayMode(p) ICOM_CALL_(RestoreDisplayMode,p,(p)) -#define IDirectDraw7_SetCooperativeLevel(p,a,b) ICOM_CALL_(SetCooperativeLevel,p,(p,a,b)) -#define IDirectDraw7_SetDisplayMode(p,a,b,c,d,e) ICOM_CALL_(SetDisplayMode,p,(p,a,b,c,d,e)) -#define IDirectDraw7_WaitForVerticalBlank(p,a,b) ICOM_CALL_(WaitForVerticalBlank,p,(p,a,b)) -/*** added in IDirectDraw2 ***/ -#define IDirectDraw7_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c)) -/*** added in IDirectDraw4 ***/ -#define IDirectDraw7_GetSurfaceFromDC(p,a,b) ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b)) -#define IDirectDraw7_RestoreAllSurfaces(p) ICOM_CALL_(RestoreAllSurfaces,p,(p)) -#define IDirectDraw7_TestCooperativeLevel(p) ICOM_CALL_(TestCooperativeLevel,p,(p)) -#define IDirectDraw7_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b)) -/*** added in IDirectDraw 7 ***/ -#define IDirectDraw7_StartModeTest(p,a,b,c) ICOM_CALL_(StartModeTest,p,(p,a,b,c)) -#define IDirectDraw7_EvaluateMode(p,a,b) ICOM_CALL_(EvaluateMode,p,(p,a,b)) - -/***************************************************************************** - * IDirectDrawSurface interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface - DECLARE_INTERFACE_(IDirectDrawSurface, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(AddAttachedSurface) (THIS_ LPDIRECTDRAWSURFACE - lpDDSAttachedSurface) PURE; - STDMETHOD(AddOverlayDirtyRect) (THIS_ LPRECT lpRect) PURE; - STDMETHOD(Blt) (THIS_ LPRECT lpDestRect, - LPDIRECTDRAWSURFACE lpDDSrcSurface, LPRECT lpSrcRect, - DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE; - STDMETHOD(BltBatch) (THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, - DWORD dwFlags) PURE; - STDMETHOD(BltFast) (THIS_ DWORD dwX, DWORD dwY, - LPDIRECTDRAWSURFACE lpDDSrcSurface, - LPRECT lpSrcRect, DWORD dwTrans) PURE; - STDMETHOD(DeleteAttachedSurface) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE - lpDDSAttachedSurface) PURE; - STDMETHOD(EnumAttachedSurfaces) (THIS_ LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(EnumOverlayZOrders) (THIS_ DWORD dwFlags, LPVOID lpContext, - LPDDENUMSURFACESCALLBACK lpfnCallback) - PURE; - STDMETHOD(Flip) (THIS_ LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, - DWORD dwFlags) PURE; - STDMETHOD(GetAttachedSurface) (THIS_ LPDDSCAPS lpDDSCaps, - LPDIRECTDRAWSURFACE * - lplpDDAttachedSurface) PURE; - STDMETHOD(GetBltStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDSCAPS lpDDSCaps) PURE; - STDMETHOD(GetClipper) (THIS_ LPDIRECTDRAWCLIPPER * lplpDDClipper) PURE; - STDMETHOD(GetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(GetDC) (THIS_ HDC * lphDC) PURE; - STDMETHOD(GetFlipStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetOverlayPosition) (THIS_ LPLONG lplX, LPLONG lplY) PURE; - STDMETHOD(GetPalette) (THIS_ LPDIRECTDRAWPALETTE * lplpDDPalette) PURE; - STDMETHOD(GetPixelFormat) (THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE; - STDMETHOD(GetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, - LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(IsLost) (THIS) PURE; - STDMETHOD(Lock) (THIS_ LPRECT lpDestRect, - LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, - HANDLE hEvent) PURE; - STDMETHOD(ReleaseDC) (THIS_ HDC hDC) PURE; - STDMETHOD(Restore) (THIS) PURE; - STDMETHOD(SetClipper) (THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE; - STDMETHOD(SetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(SetOverlayPosition) (THIS_ LONG lX, LONG lY) PURE; - STDMETHOD(SetPalette) (THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID lpSurfaceData) PURE; - STDMETHOD(UpdateOverlay) (THIS_ LPRECT lpSrcRect, - LPDIRECTDRAWSURFACE lpDDDestSurface, - LPRECT lpDestRect, DWORD dwFlags, - LPDDOVERLAYFX lpDDOverlayFx) PURE; - STDMETHOD(UpdateOverlayDisplay) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(UpdateOverlayZOrder) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE lpDDSReference) - PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawSurface_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawSurface_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawSurface_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDrawSurface methods ***/ -#define IDirectDrawSurface_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a)) -#define IDirectDrawSurface_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a)) -#define IDirectDrawSurface_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c)) -#define IDirectDrawSurface_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b)) -#define IDirectDrawSurface_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c)) -#define IDirectDrawSurface_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b)) -#define IDirectDrawSurface_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a)) -#define IDirectDrawSurface_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawSurface_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a)) -#define IDirectDrawSurface_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b)) -#define IDirectDrawSurface_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a)) -#define IDirectDrawSurface_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a)) -#define IDirectDrawSurface_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a)) -#define IDirectDrawSurface_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a)) -#define IDirectDrawSurface_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a)) -#define IDirectDrawSurface_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawSurface_IsLost(p) ICOM_CALL_(IsLost,p,(p)) -#define IDirectDrawSurface_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d)) -#define IDirectDrawSurface_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a)) -#define IDirectDrawSurface_Restore(p) ICOM_CALL_(Restore,p,(p)) -#define IDirectDrawSurface_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a)) -#define IDirectDrawSurface_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b)) -#define IDirectDrawSurface_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a)) -#define IDirectDrawSurface_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a)) -#define IDirectDrawSurface_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a)) -#define IDirectDrawSurface_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b)) - -/***************************************************************************** - * IDirectDrawSurface2 interface - */ -/* Cannot inherit from IDirectDrawSurface because the LPDIRECTDRAWSURFACE parameters - * have been converted to LPDIRECTDRAWSURFACE2. - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface2 - DECLARE_INTERFACE_(IDirectDrawSurface2, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(AddAttachedSurface) (THIS_ LPDIRECTDRAWSURFACE2 - lpDDSAttachedSurface) PURE; - STDMETHOD(AddOverlayDirtyRect) (THIS_ LPRECT lpRect) PURE; - STDMETHOD(Blt) (THIS_ LPRECT lpDestRect, - LPDIRECTDRAWSURFACE2 lpDDSrcSurface, LPRECT lpSrcRect, - DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE; - STDMETHOD(BltBatch) (THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, - DWORD dwFlags) PURE; - STDMETHOD(BltFast) (THIS_ DWORD dwX, DWORD dwY, - LPDIRECTDRAWSURFACE2 lpDDSrcSurface, - LPRECT lpSrcRect, DWORD dwTrans) PURE; - STDMETHOD(DeleteAttachedSurface) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE2 - lpDDSAttachedSurface) PURE; - STDMETHOD(EnumAttachedSurfaces) (THIS_ LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(EnumOverlayZOrders) (THIS_ DWORD dwFlags, LPVOID lpContext, - LPDDENUMSURFACESCALLBACK lpfnCallback) - PURE; - STDMETHOD(Flip) (THIS_ LPDIRECTDRAWSURFACE2 lpDDSurfaceTargetOverride, - DWORD dwFlags) PURE; - STDMETHOD(GetAttachedSurface) (THIS_ LPDDSCAPS lpDDSCaps, - LPDIRECTDRAWSURFACE2 * - lplpDDAttachedSurface) PURE; - STDMETHOD(GetBltStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDSCAPS lpDDSCaps) PURE; - STDMETHOD(GetClipper) (THIS_ LPDIRECTDRAWCLIPPER * lplpDDClipper) PURE; - STDMETHOD(GetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(GetDC) (THIS_ HDC * lphDC) PURE; - STDMETHOD(GetFlipStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetOverlayPosition) (THIS_ LPLONG lplX, LPLONG lplY) PURE; - STDMETHOD(GetPalette) (THIS_ LPDIRECTDRAWPALETTE * lplpDDPalette) PURE; - STDMETHOD(GetPixelFormat) (THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE; - STDMETHOD(GetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, - LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(IsLost) (THIS) PURE; - STDMETHOD(Lock) (THIS_ LPRECT lpDestRect, - LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, - HANDLE hEvent) PURE; - STDMETHOD(ReleaseDC) (THIS_ HDC hDC) PURE; - STDMETHOD(Restore) (THIS) PURE; - STDMETHOD(SetClipper) (THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE; - STDMETHOD(SetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(SetOverlayPosition) (THIS_ LONG lX, LONG lY) PURE; - STDMETHOD(SetPalette) (THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID lpSurfaceData) PURE; - STDMETHOD(UpdateOverlay) (THIS_ LPRECT lpSrcRect, - LPDIRECTDRAWSURFACE2 lpDDDestSurface, - LPRECT lpDestRect, DWORD dwFlags, - LPDDOVERLAYFX lpDDOverlayFx) PURE; - STDMETHOD(UpdateOverlayDisplay) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(UpdateOverlayZOrder) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE2 lpDDSReference) - PURE; - /* added in v2 */ - STDMETHOD(GetDDInterface) (THIS_ LPVOID * lplpDD) PURE; - STDMETHOD(PageLock) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(PageUnlock) (THIS_ DWORD dwFlags) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawSurface2_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawSurface2_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawSurface2_Release(p) ICOM_CALL_(Release,p,(p)) -/*** IDirectDrawSurface methods (almost) ***/ -#define IDirectDrawSurface2_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a)) -#define IDirectDrawSurface2_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a)) -#define IDirectDrawSurface2_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface2_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c)) -#define IDirectDrawSurface2_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface2_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface2_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b)) -#define IDirectDrawSurface2_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c)) -#define IDirectDrawSurface2_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b)) -#define IDirectDrawSurface2_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface2_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a)) -#define IDirectDrawSurface2_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawSurface2_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a)) -#define IDirectDrawSurface2_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b)) -#define IDirectDrawSurface2_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a)) -#define IDirectDrawSurface2_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a)) -#define IDirectDrawSurface2_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface2_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a)) -#define IDirectDrawSurface2_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a)) -#define IDirectDrawSurface2_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a)) -#define IDirectDrawSurface2_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawSurface2_IsLost(p) ICOM_CALL_(IsLost,p,(p)) -#define IDirectDrawSurface2_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d)) -#define IDirectDrawSurface2_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a)) -#define IDirectDrawSurface2_Restore(p) ICOM_CALL_(Restore,p,(p)) -#define IDirectDrawSurface2_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a)) -#define IDirectDrawSurface2_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b)) -#define IDirectDrawSurface2_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface2_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a)) -#define IDirectDrawSurface2_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a)) -#define IDirectDrawSurface2_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface2_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a)) -#define IDirectDrawSurface2_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b)) -/*** IDirectDrawSurface2 methods ***/ -#define IDirectDrawSurface2_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a)) -#define IDirectDrawSurface2_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a)) -#define IDirectDrawSurface2_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a)) - -/***************************************************************************** - * IDirectDrawSurface3 interface - */ -/* Cannot inherit from IDirectDrawSurface2 because the LPDIRECTDRAWSURFACE2 parameters - * have been converted to LPDIRECTDRAWSURFACE3. - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface3 - DECLARE_INTERFACE_(IDirectDrawSurface3, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(AddAttachedSurface) (THIS_ LPDIRECTDRAWSURFACE3 - lpDDSAttachedSurface) PURE; - STDMETHOD(AddOverlayDirtyRect) (THIS_ LPRECT lpRect) PURE; - STDMETHOD(Blt) (THIS_ LPRECT lpDestRect, - LPDIRECTDRAWSURFACE3 lpDDSrcSurface, LPRECT lpSrcRect, - DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE; - STDMETHOD(BltBatch) (THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, - DWORD dwFlags) PURE; - STDMETHOD(BltFast) (THIS_ DWORD dwX, DWORD dwY, - LPDIRECTDRAWSURFACE3 lpDDSrcSurface, - LPRECT lpSrcRect, DWORD dwTrans) PURE; - STDMETHOD(DeleteAttachedSurface) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE3 - lpDDSAttachedSurface) PURE; - STDMETHOD(EnumAttachedSurfaces) (THIS_ LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(EnumOverlayZOrders) (THIS_ DWORD dwFlags, LPVOID lpContext, - LPDDENUMSURFACESCALLBACK lpfnCallback) - PURE; - STDMETHOD(Flip) (THIS_ LPDIRECTDRAWSURFACE3 lpDDSurfaceTargetOverride, - DWORD dwFlags) PURE; - STDMETHOD(GetAttachedSurface) (THIS_ LPDDSCAPS lpDDSCaps, - LPDIRECTDRAWSURFACE3 * - lplpDDAttachedSurface) PURE; - STDMETHOD(GetBltStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDSCAPS lpDDSCaps) PURE; - STDMETHOD(GetClipper) (THIS_ LPDIRECTDRAWCLIPPER * lplpDDClipper) PURE; - STDMETHOD(GetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(GetDC) (THIS_ HDC * lphDC) PURE; - STDMETHOD(GetFlipStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetOverlayPosition) (THIS_ LPLONG lplX, LPLONG lplY) PURE; - STDMETHOD(GetPalette) (THIS_ LPDIRECTDRAWPALETTE * lplpDDPalette) PURE; - STDMETHOD(GetPixelFormat) (THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE; - STDMETHOD(GetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, - LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(IsLost) (THIS) PURE; - STDMETHOD(Lock) (THIS_ LPRECT lpDestRect, - LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, - HANDLE hEvent) PURE; - STDMETHOD(ReleaseDC) (THIS_ HDC hDC) PURE; - STDMETHOD(Restore) (THIS) PURE; - STDMETHOD(SetClipper) (THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE; - STDMETHOD(SetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(SetOverlayPosition) (THIS_ LONG lX, LONG lY) PURE; - STDMETHOD(SetPalette) (THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE; - STDMETHOD(Unlock) (THIS_ LPVOID lpSurfaceData) PURE; - STDMETHOD(UpdateOverlay) (THIS_ LPRECT lpSrcRect, - LPDIRECTDRAWSURFACE3 lpDDDestSurface, - LPRECT lpDestRect, DWORD dwFlags, - LPDDOVERLAYFX lpDDOverlayFx) PURE; - STDMETHOD(UpdateOverlayDisplay) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(UpdateOverlayZOrder) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE3 lpDDSReference) - PURE; - /* added in v2 */ - STDMETHOD(GetDDInterface) (THIS_ LPVOID * lplpDD) PURE; - STDMETHOD(PageLock) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(PageUnlock) (THIS_ DWORD dwFlags) PURE; - /* added in v3 */ - STDMETHOD(SetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSD, - DWORD dwFlags) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawSurface3_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawSurface3_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawSurface3_Release(p) ICOM_CALL_(Release,p,(p)) -/*** IDirectDrawSurface methods (almost) ***/ -#define IDirectDrawSurface3_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a)) -#define IDirectDrawSurface3_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a)) -#define IDirectDrawSurface3_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface3_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c)) -#define IDirectDrawSurface3_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface3_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface3_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b)) -#define IDirectDrawSurface3_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c)) -#define IDirectDrawSurface3_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b)) -#define IDirectDrawSurface3_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface3_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a)) -#define IDirectDrawSurface3_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawSurface3_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a)) -#define IDirectDrawSurface3_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b)) -#define IDirectDrawSurface3_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a)) -#define IDirectDrawSurface3_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a)) -#define IDirectDrawSurface3_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface3_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a)) -#define IDirectDrawSurface3_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a)) -#define IDirectDrawSurface3_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a)) -#define IDirectDrawSurface3_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawSurface3_IsLost(p) ICOM_CALL_(IsLost,p,(p)) -#define IDirectDrawSurface3_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d)) -#define IDirectDrawSurface3_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a)) -#define IDirectDrawSurface3_Restore(p) ICOM_CALL_(Restore,p,(p)) -#define IDirectDrawSurface3_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a)) -#define IDirectDrawSurface3_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b)) -#define IDirectDrawSurface3_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface3_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a)) -#define IDirectDrawSurface3_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a)) -#define IDirectDrawSurface3_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface3_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a)) -#define IDirectDrawSurface3_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b)) -/*** IDirectDrawSurface2 methods ***/ -#define IDirectDrawSurface3_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a)) -#define IDirectDrawSurface3_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a)) -#define IDirectDrawSurface3_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a)) -/*** IDirectDrawSurface3 methods ***/ -#define IDirectDrawSurface3_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b)) - -/***************************************************************************** - * IDirectDrawSurface4 interface - */ -/* Cannot inherit from IDirectDrawSurface2 because DDSCAPS changed to DDSCAPS2. - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface4 - DECLARE_INTERFACE_(IDirectDrawSurface4, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(AddAttachedSurface) (THIS_ LPDIRECTDRAWSURFACE4 - lpDDSAttachedSurface) PURE; - STDMETHOD(AddOverlayDirtyRect) (THIS_ LPRECT lpRect) PURE; - STDMETHOD(Blt) (THIS_ LPRECT lpDestRect, - LPDIRECTDRAWSURFACE4 lpDDSrcSurface, LPRECT lpSrcRect, - DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE; - STDMETHOD(BltBatch) (THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, - DWORD dwFlags) PURE; - STDMETHOD(BltFast) (THIS_ DWORD dwX, DWORD dwY, - LPDIRECTDRAWSURFACE4 lpDDSrcSurface, - LPRECT lpSrcRect, DWORD dwTrans) PURE; - STDMETHOD(DeleteAttachedSurface) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE4 - lpDDSAttachedSurface) PURE; - STDMETHOD(EnumAttachedSurfaces) (THIS_ LPVOID lpContext, - LPDDENUMSURFACESCALLBACK - lpEnumSurfacesCallback) PURE; - STDMETHOD(EnumOverlayZOrders) (THIS_ DWORD dwFlags, LPVOID lpContext, - LPDDENUMSURFACESCALLBACK lpfnCallback) - PURE; - STDMETHOD(Flip) (THIS_ LPDIRECTDRAWSURFACE4 lpDDSurfaceTargetOverride, - DWORD dwFlags) PURE; - STDMETHOD(GetAttachedSurface) (THIS_ LPDDSCAPS2 lpDDSCaps, - LPDIRECTDRAWSURFACE4 * - lplpDDAttachedSurface) PURE; - STDMETHOD(GetBltStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDSCAPS2 lpDDSCaps) PURE; - STDMETHOD(GetClipper) (THIS_ LPDIRECTDRAWCLIPPER * lplpDDClipper) PURE; - STDMETHOD(GetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(GetDC) (THIS_ HDC * lphDC) PURE; - STDMETHOD(GetFlipStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetOverlayPosition) (THIS_ LPLONG lplX, LPLONG lplY) PURE; - STDMETHOD(GetPalette) (THIS_ LPDIRECTDRAWPALETTE * lplpDDPalette) PURE; - STDMETHOD(GetPixelFormat) (THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE; - STDMETHOD(GetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, - LPDDSURFACEDESC lpDDSurfaceDesc) PURE; - STDMETHOD(IsLost) (THIS) PURE; - STDMETHOD(Lock) (THIS_ LPRECT lpDestRect, - LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, - HANDLE hEvent) PURE; - STDMETHOD(ReleaseDC) (THIS_ HDC hDC) PURE; - STDMETHOD(Restore) (THIS) PURE; - STDMETHOD(SetClipper) (THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE; - STDMETHOD(SetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(SetOverlayPosition) (THIS_ LONG lX, LONG lY) PURE; - STDMETHOD(SetPalette) (THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE; - STDMETHOD(Unlock) (THIS_ LPRECT lpSurfaceData) PURE; - STDMETHOD(UpdateOverlay) (THIS_ LPRECT lpSrcRect, - LPDIRECTDRAWSURFACE4 lpDDDestSurface, - LPRECT lpDestRect, DWORD dwFlags, - LPDDOVERLAYFX lpDDOverlayFx) PURE; - STDMETHOD(UpdateOverlayDisplay) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(UpdateOverlayZOrder) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE4 lpDDSReference) - PURE; - /* added in v2 */ - STDMETHOD(GetDDInterface) (THIS_ LPVOID * lplpDD) PURE; - STDMETHOD(PageLock) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(PageUnlock) (THIS_ DWORD dwFlags) PURE; - /* added in v3 */ - STDMETHOD(SetSurfaceDesc) (THIS_ LPDDSURFACEDESC lpDDSD, - DWORD dwFlags) PURE; - /* added in v4 */ - STDMETHOD(SetPrivateData) (THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData) (THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData) (THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue) (THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue) (THIS) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawSurface4_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawSurface4_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawSurface4_Release(p) ICOM_CALL_(Release,p,(p)) -/*** IDirectDrawSurface (almost) methods ***/ -#define IDirectDrawSurface4_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a)) -#define IDirectDrawSurface4_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a)) -#define IDirectDrawSurface4_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface4_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c)) -#define IDirectDrawSurface4_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface4_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface4_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b)) -#define IDirectDrawSurface4_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c)) -#define IDirectDrawSurface4_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b)) -#define IDirectDrawSurface4_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface4_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a)) -#define IDirectDrawSurface4_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawSurface4_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a)) -#define IDirectDrawSurface4_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b)) -#define IDirectDrawSurface4_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a)) -#define IDirectDrawSurface4_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a)) -#define IDirectDrawSurface4_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface4_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a)) -#define IDirectDrawSurface4_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a)) -#define IDirectDrawSurface4_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a)) -#define IDirectDrawSurface4_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawSurface4_IsLost(p) ICOM_CALL_(IsLost,p,(p)) -#define IDirectDrawSurface4_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d)) -#define IDirectDrawSurface4_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a)) -#define IDirectDrawSurface4_Restore(p) ICOM_CALL_(Restore,p,(p)) -#define IDirectDrawSurface4_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a)) -#define IDirectDrawSurface4_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b)) -#define IDirectDrawSurface4_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface4_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a)) -#define IDirectDrawSurface4_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a)) -#define IDirectDrawSurface4_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface4_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a)) -#define IDirectDrawSurface4_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b)) -/*** IDirectDrawSurface2 methods ***/ -#define IDirectDrawSurface4_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a)) -#define IDirectDrawSurface4_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a)) -#define IDirectDrawSurface4_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a)) -/*** IDirectDrawSurface3 methods ***/ -#define IDirectDrawSurface4_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b)) -/*** IDirectDrawSurface4 methods ***/ -#define IDirectDrawSurface4_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d)) -#define IDirectDrawSurface4_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c)) -#define IDirectDrawSurface4_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a)) -#define IDirectDrawSurface4_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a)) -#define IDirectDrawSurface4_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p)) - -/***************************************************************************** - * IDirectDrawSurface7 interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawSurface7 - DECLARE_INTERFACE_(IDirectDrawSurface7, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(AddAttachedSurface) (THIS_ LPDIRECTDRAWSURFACE7 - lpDDSAttachedSurface) PURE; - STDMETHOD(AddOverlayDirtyRect) (THIS_ LPRECT lpRect) PURE; - STDMETHOD(Blt) (THIS_ LPRECT lpDestRect, - LPDIRECTDRAWSURFACE7 lpDDSrcSurface, LPRECT lpSrcRect, - DWORD dwFlags, LPDDBLTFX lpDDBltFx) PURE; - STDMETHOD(BltBatch) (THIS_ LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, - DWORD dwFlags) PURE; - STDMETHOD(BltFast) (THIS_ DWORD dwX, DWORD dwY, - LPDIRECTDRAWSURFACE7 lpDDSrcSurface, - LPRECT lpSrcRect, DWORD dwTrans) PURE; - STDMETHOD(DeleteAttachedSurface) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE7 - lpDDSAttachedSurface) PURE; - STDMETHOD(EnumAttachedSurfaces) (THIS_ LPVOID lpContext, - LPDDENUMSURFACESCALLBACK7 - lpEnumSurfacesCallback) PURE; - STDMETHOD(EnumOverlayZOrders) (THIS_ DWORD dwFlags, LPVOID lpContext, - LPDDENUMSURFACESCALLBACK7 lpfnCallback) - PURE; - STDMETHOD(Flip) (THIS_ LPDIRECTDRAWSURFACE7 lpDDSurfaceTargetOverride, - DWORD dwFlags) PURE; - STDMETHOD(GetAttachedSurface) (THIS_ LPDDSCAPS2 lpDDSCaps, - LPDIRECTDRAWSURFACE7 * - lplpDDAttachedSurface) PURE; - STDMETHOD(GetBltStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetCaps) (THIS_ LPDDSCAPS2 lpDDSCaps) PURE; - STDMETHOD(GetClipper) (THIS_ LPDIRECTDRAWCLIPPER * lplpDDClipper) PURE; - STDMETHOD(GetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(GetDC) (THIS_ HDC * lphDC) PURE; - STDMETHOD(GetFlipStatus) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(GetOverlayPosition) (THIS_ LPLONG lplX, LPLONG lplY) PURE; - STDMETHOD(GetPalette) (THIS_ LPDIRECTDRAWPALETTE * lplpDDPalette) PURE; - STDMETHOD(GetPixelFormat) (THIS_ LPDDPIXELFORMAT lpDDPixelFormat) PURE; - STDMETHOD(GetSurfaceDesc) (THIS_ LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE; - STDMETHOD(Initialize) (THIS_ LPDIRECTDRAW lpDD, - LPDDSURFACEDESC2 lpDDSurfaceDesc) PURE; - STDMETHOD(IsLost) (THIS) PURE; - STDMETHOD(Lock) (THIS_ LPRECT lpDestRect, - LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, - HANDLE hEvent) PURE; - STDMETHOD(ReleaseDC) (THIS_ HDC hDC) PURE; - STDMETHOD(Restore) (THIS) PURE; - STDMETHOD(SetClipper) (THIS_ LPDIRECTDRAWCLIPPER lpDDClipper) PURE; - STDMETHOD(SetColorKey) (THIS_ DWORD dwFlags, - LPDDCOLORKEY lpDDColorKey) PURE; - STDMETHOD(SetOverlayPosition) (THIS_ LONG lX, LONG lY) PURE; - STDMETHOD(SetPalette) (THIS_ LPDIRECTDRAWPALETTE lpDDPalette) PURE; - STDMETHOD(Unlock) (THIS_ LPRECT lpSurfaceData) PURE; - STDMETHOD(UpdateOverlay) (THIS_ LPRECT lpSrcRect, - LPDIRECTDRAWSURFACE7 lpDDDestSurface, - LPRECT lpDestRect, DWORD dwFlags, - LPDDOVERLAYFX lpDDOverlayFx) PURE; - STDMETHOD(UpdateOverlayDisplay) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(UpdateOverlayZOrder) (THIS_ DWORD dwFlags, - LPDIRECTDRAWSURFACE7 lpDDSReference) - PURE; - /* added in v2 */ - STDMETHOD(GetDDInterface) (THIS_ LPVOID * lplpDD) PURE; - STDMETHOD(PageLock) (THIS_ DWORD dwFlags) PURE; - STDMETHOD(PageUnlock) (THIS_ DWORD dwFlags) PURE; - /* added in v3 */ - STDMETHOD(SetSurfaceDesc) (THIS_ LPDDSURFACEDESC2 lpDDSD, - DWORD dwFlags) PURE; - /* added in v4 */ - STDMETHOD(SetPrivateData) (THIS_ REFGUID, LPVOID, DWORD, DWORD) PURE; - STDMETHOD(GetPrivateData) (THIS_ REFGUID, LPVOID, LPDWORD) PURE; - STDMETHOD(FreePrivateData) (THIS_ REFGUID) PURE; - STDMETHOD(GetUniquenessValue) (THIS_ LPDWORD) PURE; - STDMETHOD(ChangeUniquenessValue) (THIS) PURE; - /* added in v7 */ - STDMETHOD(SetPriority) (THIS_ DWORD prio) PURE; - STDMETHOD(GetPriority) (THIS_ LPDWORD prio) PURE; - STDMETHOD(SetLOD) (THIS_ DWORD lod) PURE; - STDMETHOD(GetLOD) (THIS_ LPDWORD lod) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawSurface7_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawSurface7_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawSurface7_Release(p) ICOM_CALL_(Release,p,(p)) -/*** IDirectDrawSurface (almost) methods ***/ -#define IDirectDrawSurface7_AddAttachedSurface(p,a) ICOM_CALL_(AddAttachedSurface,p,(p,a)) -#define IDirectDrawSurface7_AddOverlayDirtyRect(p,a) ICOM_CALL_(AddOverlayDirtyRect,p,(p,a)) -#define IDirectDrawSurface7_Blt(p,a,b,c,d,e) ICOM_CALL_(Blt,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface7_BltBatch(p,a,b,c) ICOM_CALL_(BltBatch,p,(p,a,b,c)) -#define IDirectDrawSurface7_BltFast(p,a,b,c,d,e) ICOM_CALL_(BltFast,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface7_DeleteAttachedSurface(p,a,b) ICOM_CALL_(DeleteAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface7_EnumAttachedSurfaces(p,a,b) ICOM_CALL_(EnumAttachedSurfaces,p,(p,a,b)) -#define IDirectDrawSurface7_EnumOverlayZOrders(p,a,b,c) ICOM_CALL_(EnumOverlayZOrders,p,(p,a,b,c)) -#define IDirectDrawSurface7_Flip(p,a,b) ICOM_CALL_(Flip,p,(p,a,b)) -#define IDirectDrawSurface7_GetAttachedSurface(p,a,b) ICOM_CALL_(GetAttachedSurface,p,(p,a,b)) -#define IDirectDrawSurface7_GetBltStatus(p,a) ICOM_CALL_(GetBltStatus,p,(p,a)) -#define IDirectDrawSurface7_GetCaps(p,a) ICOM_CALL_(GetCaps,p,(p,a)) -#define IDirectDrawSurface7_GetClipper(p,a) ICOM_CALL_(GetClipper,p,(p,a)) -#define IDirectDrawSurface7_GetColorKey(p,a,b) ICOM_CALL_(GetColorKey,p,(p,a,b)) -#define IDirectDrawSurface7_GetDC(p,a) ICOM_CALL_(GetDC,p,(p,a)) -#define IDirectDrawSurface7_GetFlipStatus(p,a) ICOM_CALL_(GetFlipStatus,p,(p,a)) -#define IDirectDrawSurface7_GetOverlayPosition(p,a,b) ICOM_CALL_(GetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface7_GetPalette(p,a) ICOM_CALL_(GetPalette,p,(p,a)) -#define IDirectDrawSurface7_GetPixelFormat(p,a) ICOM_CALL_(GetPixelFormat,p,(p,a)) -#define IDirectDrawSurface7_GetSurfaceDesc(p,a) ICOM_CALL_(GetSurfaceDesc,p,(p,a)) -#define IDirectDrawSurface7_Initialize(p,a,b) ICOM_CALL_(Initialize,p,(p,a,b)) -#define IDirectDrawSurface7_IsLost(p) ICOM_CALL_(IsLost,p,(p)) -#define IDirectDrawSurface7_Lock(p,a,b,c,d) ICOM_CALL_(Lock,p,(p,a,b,c,d)) -#define IDirectDrawSurface7_ReleaseDC(p,a) ICOM_CALL_(ReleaseDC,p,(p,a)) -#define IDirectDrawSurface7_Restore(p) ICOM_CALL_(Restore,p,(p)) -#define IDirectDrawSurface7_SetClipper(p,a) ICOM_CALL_(SetClipper,p,(p,a)) -#define IDirectDrawSurface7_SetColorKey(p,a,b) ICOM_CALL_(SetColorKey,p,(p,a,b)) -#define IDirectDrawSurface7_SetOverlayPosition(p,a,b) ICOM_CALL_(SetOverlayPosition,p,(p,a,b)) -#define IDirectDrawSurface7_SetPalette(p,a) ICOM_CALL_(SetPalette,p,(p,a)) -#define IDirectDrawSurface7_Unlock(p,a) ICOM_CALL_(Unlock,p,(p,a)) -#define IDirectDrawSurface7_UpdateOverlay(p,a,b,c,d,e) ICOM_CALL_(UpdateOverlay,p,(p,a,b,c,d,e)) -#define IDirectDrawSurface7_UpdateOverlayDisplay(p,a) ICOM_CALL_(UpdateOverlayDisplay,p,(p,a)) -#define IDirectDrawSurface7_UpdateOverlayZOrder(p,a,b) ICOM_CALL_(UpdateOverlayZOrder,p,(p,a,b)) -/*** IDirectDrawSurface2 methods ***/ -#define IDirectDrawSurface7_GetDDInterface(p,a) ICOM_CALL_(GetDDInterface,p,(p,a)) -#define IDirectDrawSurface7_PageLock(p,a) ICOM_CALL_(PageLock,p,(p,a)) -#define IDirectDrawSurface7_PageUnlock(p,a) ICOM_CALL_(PageUnlock,p,(p,a)) -/*** IDirectDrawSurface3 methods ***/ -#define IDirectDrawSurface7_SetSurfaceDesc(p,a,b) ICOM_CALL_(SetSurfaceDesc,p,(p,a,b)) -/*** IDirectDrawSurface4 methods ***/ -#define IDirectDrawSurface7_SetPrivateData(p,a,b,c,d) ICOM_CALL_(SetPrivateData,p,(p,a,b,c,d)) -#define IDirectDrawSurface7_GetPrivateData(p,a,b,c) ICOM_CALL_(GetPrivateData,p,(p,a,b,c)) -#define IDirectDrawSurface7_FreePrivateData(p,a) ICOM_CALL_(FreePrivateData,p,(p,a)) -#define IDirectDrawSurface7_GetUniquenessValue(p,a) ICOM_CALL_(GetUniquenessValue,p,(p,a)) -#define IDirectDrawSurface7_ChangeUniquenessValue(p) ICOM_CALL_(ChangeUniquenessValue,p,(p)) -/*** IDirectDrawSurface7 methods ***/ -#define IDirectDrawSurface7_SetPriority(p,a) ICOM_CALL_(SetPriority,p,(p,a)) -#define IDirectDrawSurface7_GetPriority(p,a) ICOM_CALL_(GetPriority,p,(p,a)) -#define IDirectDrawSurface7_SetLOD(p,a) ICOM_CALL_(SetLOD,p,(p,a)) -#define IDirectDrawSurface7_GetLOD(p,a) ICOM_CALL_(GetLOD,p,(p,a)) - -/***************************************************************************** - * IDirectDrawColorControl interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawColorControl - DECLARE_INTERFACE_(IDirectDrawColorControl, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(GetColorControls) (THIS_ LPDDCOLORCONTROL lpColorControl) - PURE; - STDMETHOD(SetColorControls) (THIS_ LPDDCOLORCONTROL lpColorControl) - PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawColorControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawColorControl_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawColorControl_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDrawColorControl methods ***/ -#define IDirectDrawColorControl_GetColorControls(p,a) ICOM_CALL_(GetColorControls,p,(p,a)) -#define IDirectDrawColorControl_SetColorControls(p,a) ICOM_CALL_(SetColorControls,p,(p,a)) - -/***************************************************************************** - * IDirectDrawGammaControl interface - */ -#undef INTERFACE -#define INTERFACE IDirectDrawGammaControl - DECLARE_INTERFACE_(IDirectDrawGammaControl, IUnknown) { - STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(GetGammaRamp) (THIS_ DWORD dwFlags, - LPDDGAMMARAMP lpGammaRamp) PURE; - STDMETHOD(SetGammaRamp) (THIS_ DWORD dwFlags, - LPDDGAMMARAMP lpGammaRamp) PURE; - }; - - /*** IUnknown methods ***/ -#define IDirectDrawGammaControl_QueryInterface(p,a,b) ICOM_CALL_(QueryInterface,p,(p,a,b)) -#define IDirectDrawGammaControl_AddRef(p) ICOM_CALL_(AddRef,p,(p)) -#define IDirectDrawGammaControl_Release(p) ICOM_CALL_(Release,p,(p)) - /*** IDirectDrawGammaControl methods ***/ -#define IDirectDrawGammaControl_GetGammaRamp(p,a,b) ICOM_CALL_(GetGammaRamp,p,(p,a,b)) -#define IDirectDrawGammaControl_SetGammaRamp(p,a,b) ICOM_CALL_(SetGammaRamp,p,(p,a,b)) - - HRESULT WINAPI DirectDrawCreate(LPGUID, LPDIRECTDRAW *, LPUNKNOWN); - HRESULT WINAPI DirectDrawCreateEx(LPGUID, LPVOID *, REFIID, LPUNKNOWN); - HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA, LPVOID); - HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW, LPVOID); - -#define DirectDrawEnumerate WINELIB_NAME_AW(DirectDrawEnumerate) - HRESULT WINAPI DirectDrawCreateClipper(DWORD, LPDIRECTDRAWCLIPPER *, - LPUNKNOWN); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* defined(__cplusplus) */ - -#endif /* __XWIN_DDRAW_H */ diff --git a/hw/xwin/dri/meson.build b/hw/xwin/dri/meson.build deleted file mode 100644 index 0d8703c38..000000000 --- a/hw/xwin/dri/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -srcs_windows_dri = [ - 'windowsdri.c', - 'windowsdri.h', -] - -xwin_windowsdri = static_library( - 'WindowsDRI', - srcs_windows_dri, - include_directories: [ inc, include_directories('../') ], - dependencies: [ - windowsdri_dep, - pixman_dep, - ], -) diff --git a/hw/xwin/dri/windowsdri.c b/hw/xwin/dri/windowsdri.c deleted file mode 100644 index 3666e97dd..000000000 --- a/hw/xwin/dri/windowsdri.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright © 2014 Jon Turney - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/extensions/windowsdristr.h> - -#include "dixstruct.h" -#include "extnsionst.h" -#include "scrnintstr.h" -#include "swaprep.h" -#include "protocol-versions.h" -#include "windowsdri.h" -#include "glx/dri_helpers.h" - -static int WindowsDRIErrorBase = 0; -static unsigned char WindowsDRIReqCode = 0; -static int WindowsDRIEventBase = 0; - -static void -WindowsDRIResetProc(ExtensionEntry* extEntry) -{ -} - -static int -ProcWindowsDRIQueryVersion(ClientPtr client) -{ - xWindowsDRIQueryVersionReply rep; - - REQUEST_SIZE_MATCH(xWindowsDRIQueryVersionReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - rep.majorVersion = SERVER_WINDOWSDRI_MAJOR_VERSION; - rep.minorVersion = SERVER_WINDOWSDRI_MINOR_VERSION; - rep.patchVersion = SERVER_WINDOWSDRI_PATCH_VERSION; - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.majorVersion); - swaps(&rep.minorVersion); - swapl(&rep.patchVersion); - } - WriteToClient(client, sizeof(xWindowsDRIQueryVersionReply), &rep); - return Success; -} - -static int -ProcWindowsDRIQueryDirectRenderingCapable(ClientPtr client) -{ - xWindowsDRIQueryDirectRenderingCapableReply rep; - - REQUEST(xWindowsDRIQueryDirectRenderingCapableReq); - REQUEST_SIZE_MATCH(xWindowsDRIQueryDirectRenderingCapableReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - if (!client->local) - rep.isCapable = 0; - else - rep.isCapable = glxWinGetScreenAiglxIsActive(screenInfo.screens[stuff->screen]); - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - } - - WriteToClient(client, - sizeof(xWindowsDRIQueryDirectRenderingCapableReply), - &rep); - return Success; -} - -static int -ProcWindowsDRIQueryDrawable(ClientPtr client) -{ - xWindowsDRIQueryDrawableReply rep; - int rc; - - REQUEST(xWindowsDRIQueryDrawableReq); - REQUEST_SIZE_MATCH(xWindowsDRIQueryDrawableReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rc = glxWinQueryDrawable(client, stuff->drawable, &(rep.drawable_type), &(rep.handle)); - - if (rc) - return rc; - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.handle); - swapl(&rep.drawable_type); - } - - WriteToClient(client, sizeof(xWindowsDRIQueryDrawableReply), &rep); - return Success; -} - -static int -ProcWindowsDRIFBConfigToPixelFormat(ClientPtr client) -{ - xWindowsDRIFBConfigToPixelFormatReply rep; - - REQUEST(xWindowsDRIFBConfigToPixelFormatReq); - REQUEST_SIZE_MATCH(xWindowsDRIFBConfigToPixelFormatReq); - rep.type = X_Reply; - rep.length = 0; - rep.sequenceNumber = client->sequence; - - rep.pixelFormatIndex = glxWinFBConfigIDToPixelFormatIndex(stuff->screen, stuff->fbConfigID); - - if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swapl(&rep.pixelFormatIndex); - } - - WriteToClient(client, sizeof(xWindowsDRIFBConfigToPixelFormatReply), &rep); - return Success; -} - -/* dispatch */ - -static int -ProcWindowsDRIDispatch(ClientPtr client) -{ - REQUEST(xReq); - - switch (stuff->data) { - case X_WindowsDRIQueryVersion: - return ProcWindowsDRIQueryVersion(client); - - case X_WindowsDRIQueryDirectRenderingCapable: - return ProcWindowsDRIQueryDirectRenderingCapable(client); - } - - if (!client->local) - return WindowsDRIErrorBase + WindowsDRIClientNotLocal; - - switch (stuff->data) { - case X_WindowsDRIQueryDrawable: - return ProcWindowsDRIQueryDrawable(client); - - case X_WindowsDRIFBConfigToPixelFormat: - return ProcWindowsDRIFBConfigToPixelFormat(client); - - default: - return BadRequest; - } -} - -static void -SNotifyEvent(xWindowsDRINotifyEvent *from, - xWindowsDRINotifyEvent *to) -{ - to->type = from->type; - to->kind = from->kind; - cpswaps(from->sequenceNumber, to->sequenceNumber); - cpswapl(from->time, to->time); -} - -static int -SProcWindowsDRIQueryVersion(ClientPtr client) -{ - REQUEST(xWindowsDRIQueryVersionReq); - swaps(&stuff->length); - return ProcWindowsDRIQueryVersion(client); -} - -static int -SProcWindowsDRIQueryDirectRenderingCapable(ClientPtr client) -{ - REQUEST(xWindowsDRIQueryDirectRenderingCapableReq); - swaps(&stuff->length); - swapl(&stuff->screen); - return ProcWindowsDRIQueryDirectRenderingCapable(client); -} - -static int -SProcWindowsDRIQueryDrawable(ClientPtr client) -{ - REQUEST(xWindowsDRIQueryDrawableReq); - swaps(&stuff->length); - swapl(&stuff->screen); - swapl(&stuff->drawable); - return ProcWindowsDRIQueryDrawable(client); -} - -static int -SProcWindowsDRIFBConfigToPixelFormat(ClientPtr client) -{ - REQUEST(xWindowsDRIFBConfigToPixelFormatReq); - swaps(&stuff->length); - swapl(&stuff->screen); - swapl(&stuff->fbConfigID); - return ProcWindowsDRIFBConfigToPixelFormat(client); -} - -static int -SProcWindowsDRIDispatch(ClientPtr client) -{ - REQUEST(xReq); - - switch (stuff->data) { - case X_WindowsDRIQueryVersion: - return SProcWindowsDRIQueryVersion(client); - - case X_WindowsDRIQueryDirectRenderingCapable: - return SProcWindowsDRIQueryDirectRenderingCapable(client); - } - - if (!client->local) - return WindowsDRIErrorBase + WindowsDRIClientNotLocal; - - switch (stuff->data) { - case X_WindowsDRIQueryDrawable: - return SProcWindowsDRIQueryDrawable(client); - - case X_WindowsDRIFBConfigToPixelFormat: - return SProcWindowsDRIFBConfigToPixelFormat(client); - - default: - return BadRequest; - } -} - -void -WindowsDRIExtensionInit(void) -{ - ExtensionEntry* extEntry; - - if ((extEntry = AddExtension(WINDOWSDRINAME, - WindowsDRINumberEvents, - WindowsDRINumberErrors, - ProcWindowsDRIDispatch, - SProcWindowsDRIDispatch, - WindowsDRIResetProc, - StandardMinorOpcode))) { - size_t i; - WindowsDRIReqCode = (unsigned char)extEntry->base; - WindowsDRIErrorBase = extEntry->errorBase; - WindowsDRIEventBase = extEntry->eventBase; - for (i = 0; i < WindowsDRINumberEvents; i++) - EventSwapVector[WindowsDRIEventBase + i] = (EventSwapPtr)SNotifyEvent; - } -} diff --git a/hw/xwin/dri/windowsdri.h b/hw/xwin/dri/windowsdri.h deleted file mode 100644 index ce5769f1a..000000000 --- a/hw/xwin/dri/windowsdri.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright © 2014 Jon Turney - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef windowsdri_h -#define windowsdri_h - -void WindowsDRIExtensionInit(void); - -#endif /* windowsdri_h */ diff --git a/hw/xwin/glx/.gitignore b/hw/xwin/glx/.gitignore deleted file mode 100644 index 9684410ac..000000000 --- a/hw/xwin/glx/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# ignore generated files -diag.txt -generated_gl_shim.c -generated_gl_thunks.c -generated_gl_thunks.def -generated_wgl_wrappers.c diff --git a/hw/xwin/glx/dri_helpers.c b/hw/xwin/glx/dri_helpers.c deleted file mode 100644 index 5ccec74b6..000000000 --- a/hw/xwin/glx/dri_helpers.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright © 2014 Jon Turney - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <glx/glxserver.h> -#include <glx/glxutil.h> -#include <X11/extensions/windowsdriconst.h> - -#include "indirect.h" -#include "winpriv.h" -#include "dri_helpers.h" -#include "win.h" - -int -glxWinQueryDrawable(ClientPtr client, XID drawId, unsigned int *type, unsigned int *handle) -{ - __GLXWinDrawable *pDrawable; - int err; - - if (validGlxDrawable(client, drawId, GLX_DRAWABLE_ANY, - DixReadAccess, (__GLXdrawable **)&pDrawable, &err)) { - - switch (pDrawable->base.type) - { - case GLX_DRAWABLE_WINDOW: - { - HWND h = winGetWindowInfo((WindowPtr)(pDrawable->base.pDraw)); - *handle = (uintptr_t)h; - *type = WindowsDRIDrawableWindow; - } - break; - - case GLX_DRAWABLE_PIXMAP: - glxWinDeferredCreateDrawable(pDrawable, pDrawable->base.config); - *handle = pDrawable->base.pDraw->id; - // The XID is used to create a unique name for a file mapping - // shared with the requesting process - // - // XXX: Alternatively, we could use an anonymous file mapping - // and use DuplicateHandle to make pDrawable->hSection available - // to the requesting process... ? - *type = WindowsDRIDrawablePixmap; - break; - - case GLX_DRAWABLE_PBUFFER: - glxWinDeferredCreateDrawable(pDrawable, pDrawable->base.config); - *handle = (uintptr_t)(pDrawable->hPbuffer); - *type = WindowsDRIDrawablePbuffer; - break; - - default: - assert(FALSE); - *handle = 0; - } - } - else { - HWND h; - /* The drawId XID doesn't identify a GLX drawable. The only other valid - alternative is that it is the XID of a window drawable that is being - used by the pre-GLX 1.3 interface */ - DrawablePtr pDraw; - int rc = dixLookupDrawable(&pDraw, drawId, client, 0, DixGetAttrAccess); - if (rc != Success || pDraw->type != DRAWABLE_WINDOW) { - return err; - } - - h = winGetWindowInfo((WindowPtr)(pDraw)); - *handle = (uintptr_t)h; - *type = WindowsDRIDrawableWindow; - } - - winDebug("glxWinQueryDrawable: type %d, handle %p\n", *type, (void *)(uintptr_t)*handle); - return Success; -} - -int -glxWinFBConfigIDToPixelFormatIndex(int scr, int fbConfigID) -{ - __GLXscreen *screen = glxGetScreen(screenInfo.screens[scr]); - __GLXconfig *c; - - for (c = screen->fbconfigs; - c != NULL; - c = c->next) { - if (c->fbconfigID == fbConfigID) - return ((GLXWinConfig *)c)->pixelFormatIndex; - } - - return 0; -} - -Bool -glxWinGetScreenAiglxIsActive(ScreenPtr pScreen) -{ - winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen); - return pWinScreen->fNativeGlActive; -} diff --git a/hw/xwin/glx/dri_helpers.h b/hw/xwin/glx/dri_helpers.h deleted file mode 100644 index a32c965d7..000000000 --- a/hw/xwin/glx/dri_helpers.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright © 2014 Jon Turney - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef dri_helpers_h -#define dri_helpers_h - -#include "dixstruct.h" - -int -glxWinQueryDrawable(ClientPtr client, XID drawId, unsigned int *type, unsigned int *handle); - -int -glxWinFBConfigIDToPixelFormatIndex(int scr, int fbConfigID); - -Bool -glxWinGetScreenAiglxIsActive(ScreenPtr pScreen); - -#endif /* dri_helpers_h */ diff --git a/hw/xwin/glx/gen_gl_wrappers.py b/hw/xwin/glx/gen_gl_wrappers.py deleted file mode 100755 index b9e8dda75..000000000 --- a/hw/xwin/glx/gen_gl_wrappers.py +++ /dev/null @@ -1,471 +0,0 @@ -#!/usr/bin/python3 -# -# python script to generate cdecl to stdcall wrappers for GL functions -# adapted from genheaders.py -# -# Copyright (c) 2013 The Khronos Group Inc. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and/or associated documentation files (the -# "Materials"), to deal in the Materials without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Materials, and to -# permit persons to whom the Materials are 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 Materials. -# -# THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - -import sys, time, pdb, string, cProfile -from reg import * - -# Default input / log files -errFilename = None -diagFilename = 'diag.txt' -regFilename = 'gl.xml' -outFilename = 'gen_gl_wrappers.c' - -protect=True -prefix="gl" -preresolve=False -wrapper=False -shim=False -thunk=False -thunkdefs=False -staticwrappers=False -nodebug=False - -# list of WGL extension functions we use -used_wgl_ext_fns = {key: 1 for key in [ - "wglSwapIntervalEXT", - "wglGetExtensionsStringARB", - "wglDestroyPbufferARB", - "wglGetPbufferDCARB", - "wglReleasePbufferDCARB", - "wglCreatePbufferARB", - "wglMakeContextCurrentARB", - "wglChoosePixelFormatARB", - "wglGetPixelFormatAttribivARB", - "wglGetPixelFormatAttribivARB" -]} - -if __name__ == '__main__': - i = 1 - while (i < len(sys.argv)): - arg = sys.argv[i] - i = i + 1 - if (arg == '-noprotect'): - print('Disabling inclusion protection in output headers', file=sys.stderr) - protect = False - elif (arg == '-registry'): - regFilename = sys.argv[i] - i = i+1 - print('Using registry', regFilename, file=sys.stderr) - elif (arg == '-outfile'): - outFilename = sys.argv[i] - i = i+1 - elif (arg == '-preresolve'): - preresolve=True - elif (arg == '-wrapper'): - wrapper=True - elif (arg == '-shim'): - shim=True - elif (arg == '-thunk'): - thunk=True - elif (arg == '-thunkdefs'): - thunkdefs=True - elif (arg == '-staticwrappers'): - staticwrappers=True - elif (arg == '-prefix'): - prefix = sys.argv[i] - i = i+1 - elif (arg == '-nodebug'): - nodebug = True - elif (arg[0:1] == '-'): - print('Unrecognized argument:', arg, file=sys.stderr) - exit(1) - -print('Generating', outFilename, file=sys.stderr) - -# Load & parse registry -reg = Registry() -tree = etree.parse(regFilename) -reg.loadElementTree(tree) - -if shim: - versions = '1\.[012]' -else: - versions = '.*' - -genOpts = CGeneratorOptions( - apiname = prefix, - profile = 'compatibility', - versions = versions, - emitversions = versions, - defaultExtensions = prefix, # Default extensions for GL - protectFile = protect, - protectFeature = protect, - protectProto = protect, - ) - -# create error/warning & diagnostic files -if (errFilename): - errWarn = open(errFilename,'w') -else: - errWarn = sys.stderr -diag = open(diagFilename, 'w') - -def ParseCmdRettype(cmd): - proto=noneStr(cmd.elem.find('proto')) - rettype=noneStr(proto.text) - if rettype.lower()!="void ": - plist = ([t for t in proto.itertext()]) - rettype = ''.join(plist[:-1]) - rettype=rettype.strip() - return rettype - -def ParseCmdParams(cmd): - params = cmd.elem.findall('param') - plist=[] - for param in params: - # construct the formal parameter definition from ptype and name - # elements, also using any text found around these in the - # param element, in the order it appears in the document - paramtype = '' - # also extract the formal parameter name from the name element - paramname = '' - for t in param.iter(): - if t.tag == 'ptype' or t.tag == 'param': - paramtype = paramtype + noneStr(t.text) - if t.tag == 'name': - paramname = t.text + '_' - paramtype = paramtype + ' ' + paramname - if t.tail is not None: - paramtype = paramtype + t.tail.strip() - plist.append((paramtype, paramname)) - return plist - -class PreResolveOutputGenerator(OutputGenerator): - def __init__(self, - errFile = sys.stderr, - warnFile = sys.stderr, - diagFile = sys.stdout): - OutputGenerator.__init__(self, errFile, warnFile, diagFile) - self.wrappers={} - def beginFile(self, genOpts): - self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename) - def endFile(self): - self.outFile.write('\nvoid ' + prefix + 'ResolveExtensionProcs(void)\n{\n') - for funcname in self.wrappers.keys(): - self.outFile.write( ' PRERESOLVE(PFN' + funcname.upper() + 'PROC, "' + funcname + '");\n') - self.outFile.write('}\n\n') - def beginFeature(self, interface, emit): - OutputGenerator.beginFeature(self, interface, emit) - def endFeature(self): - OutputGenerator.endFeature(self) - def genType(self, typeinfo, name): - OutputGenerator.genType(self, typeinfo, name) - def genEnum(self, enuminfo, name): - OutputGenerator.genEnum(self, enuminfo, name) - def genCmd(self, cmd, name): - OutputGenerator.genCmd(self, cmd, name) - - if prefix == 'wgl' and not name in used_wgl_ext_fns: - return - - self.outFile.write('RESOLVE_DECL(PFN' + name.upper() + 'PROC);\n') - self.wrappers[name]=1 - -class WrapperOutputGenerator(OutputGenerator): - def __init__(self, - errFile = sys.stderr, - warnFile = sys.stderr, - diagFile = sys.stdout): - OutputGenerator.__init__(self, errFile, warnFile, diagFile) - def beginFile(self, genOpts): - self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename) - def endFile(self): - pass - def beginFeature(self, interface, emit): - OutputGenerator.beginFeature(self, interface, emit) - self.OldVersion = self.featureName.startswith('GL_VERSION_1_0') or self.featureName.startswith('GL_VERSION_1_1') - def endFeature(self): - OutputGenerator.endFeature(self) - def genType(self, typeinfo, name): - OutputGenerator.genType(self, typeinfo, name) - def genEnum(self, enuminfo, name): - OutputGenerator.genEnum(self, enuminfo, name) - def genCmd(self, cmd, name): - OutputGenerator.genCmd(self, cmd, name) - - if prefix == 'wgl' and not name in used_wgl_ext_fns: - return - - rettype=ParseCmdRettype(cmd) - - if staticwrappers: self.outFile.write("static ") - self.outFile.write("%s %sWrapper("%(rettype, name)) - plist=ParseCmdParams(cmd) - Comma="" - if len(plist): - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, ptype)) - Comma=", " - else: - self.outFile.write("void") - - self.outFile.write(")\n{\n") - - # for GL 1.0 and 1.1 functions, generate stdcall wrappers which call the function directly - if self.OldVersion: - if not nodebug: - self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name)) - self.outFile.write(" glWinDirectProcCalls++;\n") - self.outFile.write("\n") - - if rettype.lower()=="void": - self.outFile.write(" %s( "%(name)) - else: - self.outFile.write(" return %s( "%(name)) - - Comma="" - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, pname)) - Comma=", " - - # for GL 1.2+ functions, generate stdcall wrappers which use wglGetProcAddress() - else: - if rettype.lower()=="void": - self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name)) - - if not nodebug: - self.outFile.write("\n") - self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name)) - self.outFile.write("\n") - - self.outFile.write(" RESOLVED_PROC(PFN%sPROC)( """%(name.upper())) - else: - self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", FALSE);\n'%(name.upper(), name)) - - if not nodebug: - self.outFile.write("\n") - self.outFile.write(' if (glxWinDebugSettings.enable%scallTrace) ErrorF("%s\\n");\n'%(prefix.upper(), name)) - self.outFile.write("\n") - - self.outFile.write(" return RESOLVED_PROC(PFN%sPROC)("%(name.upper())) - - Comma="" - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, pname)) - Comma=", " - self.outFile.write(" );\n}\n\n") - -class ThunkOutputGenerator(OutputGenerator): - def __init__(self, - errFile = sys.stderr, - warnFile = sys.stderr, - diagFile = sys.stdout): - OutputGenerator.__init__(self, errFile, warnFile, diagFile) - def beginFile(self, genOpts): - self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename) - def endFile(self): - pass - def beginFeature(self, interface, emit): - OutputGenerator.beginFeature(self, interface, emit) - self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1']) - def endFeature(self): - OutputGenerator.endFeature(self) - def genType(self, typeinfo, name): - OutputGenerator.genType(self, typeinfo, name) - def genEnum(self, enuminfo, name): - OutputGenerator.genEnum(self, enuminfo, name) - def genCmd(self, cmd, name): - OutputGenerator.genCmd(self, cmd, name) - - rettype=ParseCmdRettype(cmd) - self.outFile.write("%s %sWrapper("%(rettype, name)) - plist=ParseCmdParams(cmd) - - Comma="" - if len(plist): - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, ptype)) - Comma=", " - else: - self.outFile.write("void") - - self.outFile.write(")\n{\n") - - # for GL 1.0 and 1.1 functions, generate stdcall thunk wrappers which call the function directly - if self.OldVersion: - if rettype.lower()=="void": - self.outFile.write(" %s( "%(name)) - else: - self.outFile.write(" return %s( "%(name)) - - Comma="" - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, pname)) - Comma=", " - - # for GL 1.2+ functions, generate wrappers which use wglGetProcAddress() - else: - if rettype.lower()=="void": - self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name)) - self.outFile.write(" RESOLVED_PROC(PFN%sPROC)( """%(name.upper())) - else: - self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", FALSE);\n'%(name.upper(), name)) - self.outFile.write(" return RESOLVED_PROC(PFN%sPROC)("%(name.upper())) - - Comma="" - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, pname)) - Comma=", " - self.outFile.write(" );\n}\n\n") - -class ThunkDefsOutputGenerator(OutputGenerator): - def __init__(self, - errFile = sys.stderr, - warnFile = sys.stderr, - diagFile = sys.stdout): - OutputGenerator.__init__(self, errFile, warnFile, diagFile) - def beginFile(self, genOpts): - self.outFile.write("EXPORTS\n"); # this must be the first line for libtool to realize this is a .def file - self.outFile.write('; Automatically generated from %s - DO NOT EDIT\n\n'%regFilename) - def endFile(self): - pass - def beginFeature(self, interface, emit): - OutputGenerator.beginFeature(self, interface, emit) - def endFeature(self): - OutputGenerator.endFeature(self) - def genType(self, typeinfo, name): - OutputGenerator.genType(self, typeinfo, name) - def genEnum(self, enuminfo, name): - OutputGenerator.genEnum(self, enuminfo, name) - def genCmd(self, cmd, name): - OutputGenerator.genCmd(self, cmd, name) - - # export the wrapper function with the name of the function it wraps - self.outFile.write("%s = %sWrapper\n"%(name, name)) - -class ShimOutputGenerator(OutputGenerator): - def __init__(self, - errFile = sys.stderr, - warnFile = sys.stderr, - diagFile = sys.stdout): - OutputGenerator.__init__(self, errFile, warnFile, diagFile) - def beginFile(self, genOpts): - self.outFile.write('/* Automatically generated from %s - DO NOT EDIT */\n\n'%regFilename) - def endFile(self): - pass - def beginFeature(self, interface, emit): - OutputGenerator.beginFeature(self, interface, emit) - self.OldVersion = (self.featureName in ['GL_VERSION_1_0', 'GL_VERSION_1_1', 'GL_VERSION_1_2', 'GL_ARB_imaging', 'GL_ARB_multitexture', 'GL_ARB_texture_compression']) - def endFeature(self): - OutputGenerator.endFeature(self) - def genType(self, typeinfo, name): - OutputGenerator.genType(self, typeinfo, name) - def genEnum(self, enuminfo, name): - OutputGenerator.genEnum(self, enuminfo, name) - def genCmd(self, cmd, name): - OutputGenerator.genCmd(self, cmd, name) - - if not self.OldVersion: - return - - # for GL functions which are in the ABI, generate a shim which calls the function via GetProcAddress - rettype=ParseCmdRettype(cmd) - self.outFile.write("%s %s("%(rettype, name)) - plist=ParseCmdParams(cmd) - - Comma="" - if len(plist): - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, ptype)) - Comma=", " - else: - self.outFile.write("void") - - self.outFile.write(")\n{\n") - - self.outFile.write(' typedef %s (* PFN%sPROC)(' % (rettype, name.upper())) - - if len(plist): - Comma="" - for ptype, pname in plist: - self.outFile.write("%s %s"%(Comma, ptype)) - Comma=", " - else: - self.outFile.write("void") - - self.outFile.write(');\n') - - if rettype.lower()=="void": - self.outFile.write(' RESOLVE(PFN%sPROC, "%s");\n'%(name.upper(), name)) - self.outFile.write(' RESOLVED_PROC(') - else: - self.outFile.write(' RESOLVE_RET(PFN%sPROC, "%s", 0);\n'%(name.upper(), name)) - self.outFile.write(' return RESOLVED_PROC(') - - Comma="" - for ptype, pname in plist: - self.outFile.write("%s%s"%(Comma, pname)) - Comma=", " - - self.outFile.write(" );\n}\n\n") - -def genHeaders(): - outFile = open(outFilename,"w") - - if preresolve: - gen = PreResolveOutputGenerator(errFile=errWarn, - warnFile=errWarn, - diagFile=diag) - gen.outFile=outFile - reg.setGenerator(gen) - reg.apiGen(genOpts) - - if wrapper: - gen = WrapperOutputGenerator(errFile=errWarn, - warnFile=errWarn, - diagFile=diag) - gen.outFile=outFile - reg.setGenerator(gen) - reg.apiGen(genOpts) - - if shim: - gen = ShimOutputGenerator(errFile=errWarn, - warnFile=errWarn, - diagFile=diag) - gen.outFile=outFile - reg.setGenerator(gen) - reg.apiGen(genOpts) - - if thunk: - gen = ThunkOutputGenerator(errFile=errWarn, - warnFile=errWarn, - diagFile=diag) - gen.outFile=outFile - reg.setGenerator(gen) - reg.apiGen(genOpts) - - - if thunkdefs: - gen = ThunkDefsOutputGenerator(errFile=errWarn, - warnFile=errWarn, - diagFile=diag) - gen.outFile=outFile - reg.setGenerator(gen) - reg.apiGen(genOpts) - - outFile.close() - -genHeaders() diff --git a/hw/xwin/glx/glshim.c b/hw/xwin/glx/glshim.c deleted file mode 100644 index a27040257..000000000 --- a/hw/xwin/glx/glshim.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * File: glshim.c - * Purpose: GL shim which redirects to a specified DLL - * - * Copyright (c) Jon TURNEY 2013 - * - * 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. - */ - -/* - A GL shim which redirects to a specified DLL - - XWin is statically linked with this, rather than the system libGL, so that - GL calls can be directed to mesa cygGL-1.dll, or cygnativeGLthunk.dll - (which contains cdecl-to-stdcall thunks to the native openGL32.dll) -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#define GL_GLEXT_LEGACY -#define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#undef GL_ARB_imaging -#undef GL_VERSION_1_3 -#include <GL/glext.h> - -#include <X11/Xwindows.h> -#include <os.h> -#include "glwindows.h" -#include <glx/glxserver.h> - -extern void *glXGetProcAddressARB(const char *); - -static HMODULE hMod = NULL; - -/* - Implement the __glGetProcAddress function by just using GetProcAddress() on the selected DLL -*/ -void *glXGetProcAddressARB(const char *symbol) -{ - void *proc; - - /* Default to the mesa GL implementation if one hasn't been selected yet */ - if (!hMod) - glWinSelectImplementation(0); - - proc = GetProcAddress(hMod, symbol); - - if (glxWinDebugSettings.enableGLcallTrace) - ErrorF("glXGetProcAddressARB: Resolved '%s' in %p to %p\n", symbol, hMod, proc); - - return proc; -} - -/* - Select a GL implementation DLL -*/ -int glWinSelectImplementation(int native) -{ - const char *dllname; - - if (native) { - dllname = "cygnativeGLthunk.dll"; - } - else { - dllname = "cygGL-1.dll"; - } - - hMod = LoadLibraryEx(dllname, NULL, 0); - if (hMod == NULL) { - ErrorF("glWinSelectGLimplementation: Could not load '%s'\n", dllname); - return -1; - } - - ErrorF("glWinSelectGLimplementation: Loaded '%s'\n", dllname); - - /* Connect __glGetProcAddress() to our implementation of glXGetProcAddressARB() above */ - __glXsetGetProcAddress((glx_gpa_proc)glXGetProcAddressARB); - - return 0; -} - -#define RESOLVE_RET(proctype, symbol, retval) \ - proctype proc = (proctype)glXGetProcAddressARB(symbol); \ - if (proc == NULL) return retval; - -#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,) -#define RESOLVED_PROC proc - -/* Include generated shims for direct linkage to GL functions which are in the ABI */ -#include "generated_gl_shim.ic" - -/* - Special wrapper for glAddSwapHintRectWIN for copySubBuffers - - Only used with native GL if the GL_WIN_swap_hint extension is present, so we enable - GLX_MESA_copy_sub_buffer -*/ -typedef void (__stdcall * PFNGLADDSWAPHINTRECTWIN) (GLint x, GLint y, - GLsizei width, - GLsizei height); - -void -glAddSwapHintRectWINWrapper(GLint x, GLint y, GLsizei width, - GLsizei height) -{ - RESOLVE(PFNGLADDSWAPHINTRECTWIN, "glAddSwapHintRectWIN"); - RESOLVED_PROC(x, y, width, height); -} diff --git a/hw/xwin/glx/glthunk.c b/hw/xwin/glx/glthunk.c deleted file mode 100644 index 3d2702ddb..000000000 --- a/hw/xwin/glx/glthunk.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * File: glthunk.c - * Purpose: cdecl thunk wrapper library for Win32 stdcall OpenGL library - * - * Copyright (c) Jon TURNEY 2009,2013 - * - * 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. - */ - -// define USE_OPENGL32 makes gl.h declare gl*() function prototypes with stdcall linkage, -// so our generated wrappers will correctly link with the functions in opengl32.dll -#define USE_OPENGL32 - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <X11/Xwindows.h> - -#define GL_GLEXT_LEGACY -#include <GL/gl.h> -#undef GL_ARB_imaging -#undef GL_VERSION_1_3 -#include <GL/glext.h> - -static PROC -glWinResolveHelper(PROC * cache, const char *symbol) -{ - PROC proc = NULL; - - /* If not yet cached, call wglGetProcAddress */ - if ((*cache) == NULL) { - proc = wglGetProcAddress(symbol); - if (proc == NULL) { - (*cache) = (PROC) - 1; - } - else { - (*cache) = proc; - } - } - /* Cached wglGetProcAddress failure */ - else if ((*cache) == (PROC) - 1) { - proc = 0; - } - /* Cached wglGetProcAddress result */ - else { - proc = (*cache); - } - - return proc; -} - -#define RESOLVE_RET(proctype, symbol, retval) \ - static PROC cache = NULL; \ - __stdcall proctype proc = (proctype)glWinResolveHelper(&cache, symbol); \ - if (proc == NULL) { \ - return retval; \ - } - -#define RESOLVE(proctype, symbol) RESOLVE_RET(proctype, symbol,) - -#define RESOLVED_PROC(proctype) proc - -/* - Include generated cdecl wrappers for stdcall gl*() functions in opengl32.dll - - OpenGL 1.2 and upward is treated as extensions, function address must - found using wglGetProcAddress(), but also stdcall so still need wrappers... -*/ - -#include "generated_gl_thunks.ic" diff --git a/hw/xwin/glx/glwindows.h b/hw/xwin/glx/glwindows.h deleted file mode 100644 index 34ff24c24..000000000 --- a/hw/xwin/glx/glwindows.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * File: glwindows.h - * Purpose: Header for GLX implementation using native Windows OpenGL library - * - * Authors: Alexander Gottwald - * Jon TURNEY - * - * Copyright (c) Jon TURNEY 2009 - * Copyright (c) Alexander Gottwald 2004 - * - * - * 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 GLWINDOWS_H -#define GLWINDOWS_H - -#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; -} glxWinDebugSettingsRec; - -extern glxWinDebugSettingsRec glxWinDebugSettings; - -void glxWinPushNativeProvider(void); -void glAddSwapHintRectWINWrapper(GLint x, GLint y, GLsizei width, GLsizei height); -int glWinSelectImplementation(int native); - -#if 1 -#define GLWIN_TRACE_MSG(msg, args...) if (glxWinDebugSettings.enableTrace) ErrorF(msg " [%s:%d]\n" , ##args , __FUNCTION__, __LINE__ ) -#define GLWIN_DEBUG_MSG(msg, args...) if (glxWinDebugSettings.enableDebug) ErrorF(msg " [%s:%d]\n" , ##args , __FUNCTION__, __LINE__ ) -#else -#define GLWIN_TRACE_MSG(a, ...) -#define GLWIN_DEBUG_MSG(a, ...) -#endif - -#endif diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c deleted file mode 100644 index ff015f763..000000000 --- a/hw/xwin/glx/indirect.c +++ /dev/null @@ -1,2444 +0,0 @@ -/* - * File: indirect.c - * Purpose: A GLX implementation that uses Windows OpenGL library - * - * Authors: Alexander Gottwald - * Jon TURNEY - * - * Copyright (c) Jon TURNEY 2009 - * Copyright (c) Alexander Gottwald 2004 - * - * Portions of this file are copied from GL/apple/indirect.c, - * which contains the following copyright: - * - * Copyright (c) 2007, 2008, 2009 Apple Inc. - * Copyright (c) 2004 Torrey T. Lyons. All Rights Reserved. - * Copyright (c) 2002 Greg Parker. All Rights Reserved. - * - * Portions of this file are copied from Mesa's xf86glx.c, - * which contains the following copyright: - * - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - TODO: - - hook up remaining unimplemented extensions - - research what guarantees glXWaitX, glXWaitGL are supposed to offer, and implement then - using GdiFlush and/or glFinish - - pbuffer clobbering: we don't get async notification, but can we arrange to emit the - event when we notice it's been clobbered? at the very least, check if it's been clobbered - before using it? - - XGetImage() doesn't work on pixmaps; need to do more work to make the format and location - of the native pixmap compatible - - implement GLX_EXT_texture_from_pixmap in terms of WGL_ARB_render_texture - (not quite straightforward as we will have to create a pbuffer and copy the pixmap texture - into it) -*/ - -/* - Assumptions: - - the __GLXConfig * we get handed back ones we are made (so we can extend the structure - with privates) and never get created inside the GLX core -*/ - -/* - MSDN clarifications: - - It says SetPixelFormat()'s PIXELFORMATDESCRIPTOR pointer argument has no effect - except on metafiles, this seems to mean that as it's ok to supply NULL if the DC - is not for a metafile - - wglMakeCurrent ignores the hdc if hglrc is NULL, so wglMakeCurrent(NULL, NULL) - is used to make no context current - -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "glwindows.h" -#include <glx/glxserver.h> -#include <glx/glxutil.h> -#include <GL/glxtokens.h> - -#include <winpriv.h> -#include <wgl_ext_api.h> -#include <winglobals.h> -#include <indirect.h> - -/* Not yet in w32api */ -#ifndef PFD_SUPPORT_DIRECTDRAW -#define PFD_SUPPORT_DIRECTDRAW 0x00002000 -#endif -#ifndef PFD_DIRECT3D_ACCELERATED -#define PFD_DIRECT3D_ACCELERATED 0x00004000 -#endif -#ifndef PFD_SUPPORT_COMPOSITION -#define PFD_SUPPORT_COMPOSITION 0x00008000 -#endif - - -typedef struct { - int notOpenGL; - int unknownPixelType; - int unaccelerated; -} PixelFormatRejectStats; - -/* ---------------------------------------------------------------------- */ -/* - * Various debug helpers - */ - -#define GLWIN_DEBUG_HWND(hwnd) \ - if (glxWinDebugSettings.dumpHWND) { \ - char buffer[1024]; \ - if (GetWindowText(hwnd, buffer, sizeof(buffer))==0) *buffer=0; \ - GLWIN_DEBUG_MSG("Got HWND %p for window '%s'", hwnd, buffer); \ - } - -glxWinDebugSettingsRec glxWinDebugSettings = { 0, 0, 0, 0, 0, 0 }; - -static void -glxWinInitDebugSettings(void) -{ - char *envptr; - - envptr = getenv("GLWIN_ENABLE_DEBUG"); - if (envptr != NULL) - glxWinDebugSettings.enableDebug = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_ENABLE_TRACE"); - if (envptr != NULL) - glxWinDebugSettings.enableTrace = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_DUMP_PFD"); - if (envptr != NULL) - glxWinDebugSettings.dumpPFD = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_DUMP_HWND"); - if (envptr != NULL) - glxWinDebugSettings.dumpHWND = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_DUMP_DC"); - if (envptr != NULL) - glxWinDebugSettings.dumpDC = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_ENABLE_GLCALL_TRACE"); - if (envptr != NULL) - glxWinDebugSettings.enableGLcallTrace = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_ENABLE_WGLCALL_TRACE"); - if (envptr != NULL) - glxWinDebugSettings.enableWGLcallTrace = (atoi(envptr) == 1); - - envptr = getenv("GLWIN_DEBUG_ALL"); - if (envptr != NULL) { - glxWinDebugSettings.enableDebug = 1; - glxWinDebugSettings.enableTrace = 1; - glxWinDebugSettings.dumpPFD = 1; - glxWinDebugSettings.dumpHWND = 1; - glxWinDebugSettings.dumpDC = 1; - glxWinDebugSettings.enableGLcallTrace = 1; - glxWinDebugSettings.enableWGLcallTrace = 1; - } -} - -static -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"); - } - - if ((errorbuffer[strlen(errorbuffer) - 1] == '\n') || - (errorbuffer[strlen(errorbuffer) - 1] == '\r')) - errorbuffer[strlen(errorbuffer) - 1] = 0; - - sprintf(errorbuffer + strlen(errorbuffer), " (%08x)", last_error); - - return errorbuffer; -} - -static void pfdOut(const PIXELFORMATDESCRIPTOR * pfd); - -#define DUMP_PFD_FLAG(flag) \ - if (pfd->dwFlags & flag) { \ - ErrorF("%s%s", pipesym, #flag); \ - pipesym = " | "; \ - } - -static void -pfdOut(const PIXELFORMATDESCRIPTOR * pfd) -{ - 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 = %u = {", (unsigned int)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); - ErrorF("}\n"); - - ErrorF("iPixelType = %hu = %s\n", pfd->iPixelType, - (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); - ErrorF("cGreenBits = %hhu\n", pfd->cGreenBits); - ErrorF("cGreenShift = %hhu\n", pfd->cGreenShift); - ErrorF("cBlueBits = %hhu\n", pfd->cBlueBits); - ErrorF("cBlueShift = %hhu\n", pfd->cBlueShift); - ErrorF("cAlphaBits = %hhu\n", pfd->cAlphaBits); - ErrorF("cAlphaShift = %hhu\n", pfd->cAlphaShift); - ErrorF("cAccumBits = %hhu\n", pfd->cAccumBits); - ErrorF("cAccumRedBits = %hhu\n", pfd->cAccumRedBits); - ErrorF("cAccumGreenBits = %hhu\n", pfd->cAccumGreenBits); - ErrorF("cAccumBlueBits = %hhu\n", pfd->cAccumBlueBits); - ErrorF("cAccumAlphaBits = %hhu\n", pfd->cAccumAlphaBits); - ErrorF("cDepthBits = %hhu\n", pfd->cDepthBits); - ErrorF("cStencilBits = %hhu\n", pfd->cStencilBits); - ErrorF("cAuxBuffers = %hhu\n", pfd->cAuxBuffers); - ErrorF("iLayerType = %hhu\n", pfd->iLayerType); - ErrorF("bReserved = %hhu\n", pfd->bReserved); - ErrorF("dwLayerMask = %u\n", (unsigned int)pfd->dwLayerMask); - ErrorF("dwVisibleMask = %u\n", (unsigned int)pfd->dwVisibleMask); - ErrorF("dwDamageMask = %u\n", (unsigned int)pfd->dwDamageMask); - ErrorF("\n"); -} - -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-"; - } -} - -static const char * -swap_method_name(int mthd) -{ - switch (mthd) { - case GLX_SWAP_EXCHANGE_OML: - return "xchg"; - case GLX_SWAP_COPY_OML: - return "copy"; - case GLX_SWAP_UNDEFINED_OML: - return " "; - default: - return "????"; - } -} - -static void -fbConfigsDump(unsigned int n, __GLXconfig * c, PixelFormatRejectStats *rejects) -{ - LogMessage(X_INFO, "%d fbConfigs\n", n); - LogMessage(X_INFO, "ignored pixel formats: %d not OpenGL, %d unknown pixel type, %d unaccelerated\n", - rejects->notOpenGL, rejects->unknownPixelType, rejects->unaccelerated); - - if (g_iLogVerbose < 3) - return; - - ErrorF - ("pxf vis fb render Ste aux accum MS drawable Group/ sRGB\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 cap \n"); - ErrorF - ("----------------------------------------------------------------------------------------------------------------------------------\n"); - - while (c != NULL) { - unsigned int i = ((GLXWinConfig *) c)->pixelFormatIndex; - - const char *float_col = "."; - if (c->renderType & GLX_RGBA_FLOAT_BIT_ARB) float_col = "s"; - if (c->renderType & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) float_col = "u"; - - 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 " - " %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" : ".", - float_col, - (c->transparentPixel != GLX_NONE_EXT) ? "y" : ".", - c->visualSelectGroup, - (c->visualRating == GLX_SLOW_VISUAL_EXT) ? "*" : " ", - c->sRGBCapable ? "y" : "."); - - c = c->next; - } -} - -/* ---------------------------------------------------------------------- */ -/* - * Forward declarations - */ - -static __GLXscreen *glxWinScreenProbe(ScreenPtr pScreen); -static __GLXcontext *glxWinCreateContext(__GLXscreen * screen, - __GLXconfig * modes, - __GLXcontext * baseShareContext, - unsigned num_attribs, - const uint32_t * attribs, int *error); -static __GLXdrawable *glxWinCreateDrawable(ClientPtr client, - __GLXscreen * screen, - DrawablePtr pDraw, - XID drawId, - int type, - XID glxDrawId, __GLXconfig * conf); - -static Bool glxWinRealizeWindow(WindowPtr pWin); -static Bool glxWinUnrealizeWindow(WindowPtr pWin); -static void glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, - RegionPtr prgnSrc); -static Bool glxWinSetPixelFormat(HDC hdc, int bppOverride, int drawableTypeOverride, - __GLXscreen *screen, __GLXconfig *config); -static HDC glxWinMakeDC(__GLXWinContext * gc, __GLXWinDrawable * draw, - HDC * hdc, 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, - PixelFormatRejectStats * rejects); -static int fbConfigToPixelFormat(__GLXconfig * mode, - PIXELFORMATDESCRIPTOR * pfdret, - int drawableTypeOverride); -static int fbConfigToPixelFormatIndex(HDC hdc, __GLXconfig * mode, - int drawableTypeOverride, - glxWinScreen * winScreen); - -/* ---------------------------------------------------------------------- */ -/* - * The GLX provider - */ - -__GLXprovider __glXWGLProvider = { - glxWinScreenProbe, - "Win32 native WGL", - NULL -}; - -void -glxWinPushNativeProvider(void) -{ - GlxPushProvider(&__glXWGLProvider); -} - -/* ---------------------------------------------------------------------- */ -/* - * Screen functions - */ - -static void -glxWinScreenDestroy(__GLXscreen * screen) -{ - GLWIN_DEBUG_MSG("glxWinScreenDestroy(%p)", screen); - __glXScreenDestroy(screen); - free(screen); -} - -static int -glxWinScreenSwapInterval(__GLXdrawable * drawable, int interval) -{ - BOOL ret = wglSwapIntervalEXTWrapper(interval); - - if (!ret) { - ErrorF("wglSwapIntervalEXT interval %d failed:%s\n", interval, - glxWinErrorMessage()); - } - return ret; -} - -/* - Report the extensions split and formatted to avoid overflowing a line - */ -static void -glxLogExtensions(const char *prefix, const char *extensions) -{ - int length = 0; - const char *strl; - char *str = strdup(extensions); - - if (str == NULL) { - ErrorF("glxLogExtensions: xalloc error\n"); - return; - } - - strl = strtok(str, " "); - if (strl == NULL) - strl = ""; - ErrorF("%s%s", prefix, strl); - length = strlen(prefix) + strlen(strl); - - while (1) { - strl = strtok(NULL, " "); - if (strl == NULL) - break; - - if (length + strlen(strl) + 1 > 120) { - ErrorF("\n"); - ErrorF("%s", prefix); - length = strlen(prefix); - } - else { - ErrorF(" "); - length++; - } - - ErrorF("%s", strl); - length = length + strlen(strl); - } - - ErrorF("\n"); - - free(str); -} - -/* This is called by GlxExtensionInit() asking the GLX provider if it can handle the screen... */ -static __GLXscreen * -glxWinScreenProbe(ScreenPtr pScreen) -{ - glxWinScreen *screen; - const char *gl_extensions; - const char *gl_renderer; - const char *wgl_extensions; - HWND hwnd; - HDC hdc; - HGLRC hglrc; - PixelFormatRejectStats rejects; - - GLWIN_DEBUG_MSG("glxWinScreenProbe"); - - glxWinInitDebugSettings(); - - if (pScreen == NULL) - return NULL; - - 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; - - // Select the native GL implementation (WGL) - if (glWinSelectImplementation(1)) { - free(screen); - return NULL; - } - - // create window class -#define WIN_GL_TEST_WINDOW_CLASS "XWinGLTest" - { - static wATOM glTestWndClass = 0; - - if (glTestWndClass == 0) { - WNDCLASSEX wc; - - wc.cbSize = sizeof(WNDCLASSEX); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = DefWindowProc; - 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_GL_TEST_WINDOW_CLASS; - wc.hIconSm = 0; - RegisterClassEx(&wc); - } - } - - // create an invisible window for a scratch DC - hwnd = CreateWindowExA(0, - WIN_GL_TEST_WINDOW_CLASS, - "XWin GL Renderer Capabilities Test Window", - 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"); - - hdc = GetDC(hwnd); - - // we must set a pixel format before we can create a context, just use the first one... - SetPixelFormat(hdc, 1, NULL); - hglrc = wglCreateContext(hdc); - wglMakeCurrent(hdc, hglrc); - - // initialize wgl extension proc pointers (don't call them before here...) - // (but we need to have a current context for them to be resolvable) - wglResolveExtensionProcs(); - - /* Dump out some useful information about the native renderer */ - ErrorF("GL_VERSION: %s\n", glGetString(GL_VERSION)); - ErrorF("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); - gl_renderer = (const char *) glGetString(GL_RENDERER); - ErrorF("GL_RENDERER: %s\n", gl_renderer); - gl_extensions = (const char *) glGetString(GL_EXTENSIONS); - wgl_extensions = wglGetExtensionsStringARBWrapper(hdc); - if (!wgl_extensions) - wgl_extensions = ""; - - if (g_iLogVerbose >= 3) { - glxLogExtensions("GL_EXTENSIONS: ", gl_extensions); - glxLogExtensions("WGL_EXTENSIONS: ", wgl_extensions); - } - - if (strcasecmp(gl_renderer, "GDI Generic") == 0) { - free(screen); - LogMessage(X_ERROR, - "AIGLX: Won't use generic native renderer as it is not accelerated\n"); - goto error; - } - - // Can you see the problem here? The extensions string is DC specific - // Different DCs for windows on a multimonitor system driven by multiple cards - // might have completely different capabilities. Of course, good luck getting - // those screens to be accelerated in XP and earlier... - - - { - int i; - - const struct - { - const char *wglext; - const char *glxext; - Bool mandatory; - } extensionMap[] = { - { "WGL_ARB_make_current_read", "GLX_SGI_make_current_read", 1 }, - { "WGL_EXT_swap_control", "GLX_SGI_swap_control", 0 }, - { "WGL_EXT_swap_control", "GLX_MESA_swap_control", 0 }, - // { "WGL_ARB_render_texture", "GLX_EXT_texture_from_pixmap", 0 }, - // Sufficiently different that it's not obvious if this can be done... - { "WGL_ARB_pbuffer", "GLX_SGIX_pbuffer", 1 }, - { "WGL_ARB_multisample", "GLX_ARB_multisample", 1 }, - { "WGL_ARB_multisample", "GLX_SGIS_multisample", 0 }, - { "WGL_ARB_pixel_format_float", "GLX_ARB_fbconfig_float", 0 }, - { "WGL_EXT_pixel_format_packed_float", "GLX_EXT_fbconfig_packed_float", 0 }, - { "WGL_ARB_create_context", "GLX_ARB_create_context", 0 }, - { "WGL_ARB_create_context_profile", "GLX_ARB_create_context_profile", 0 }, - { "WGL_ARB_create_context_robustness", "GLX_ARB_create_context_robustness", 0 }, - { "WGL_EXT_create_context_es2_profile", "GLX_EXT_create_context_es2_profile", 0 }, - { "WGL_ARB_framebuffer_sRGB", "GLX_ARB_framebuffer_sRGB", 0 }, - }; - - // - // Based on the WGL extensions available, enable various GLX extensions - // - __glXInitExtensionEnableBits(screen->base.glx_enable_bits); - - for (i = 0; i < sizeof(extensionMap)/sizeof(extensionMap[0]); i++) { - if (strstr(wgl_extensions, extensionMap[i].wglext)) { - __glXEnableExtension(screen->base.glx_enable_bits, extensionMap[i].glxext); - LogMessage(X_INFO, "GLX: enabled %s\n", extensionMap[i].glxext); - } - else if (extensionMap[i].mandatory) { - LogMessage(X_ERROR, "required WGL extension %s is missing\n", extensionMap[i].wglext); - } - } - - // Because it pre-dates WGL_EXT_extensions_string, GL_WIN_swap_hint might - // only be in GL_EXTENSIONS - if (strstr(gl_extensions, "GL_WIN_swap_hint")) { - __glXEnableExtension(screen->base.glx_enable_bits, - "GLX_MESA_copy_sub_buffer"); - LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n"); - } - - if (strstr(wgl_extensions, "WGL_ARB_make_current_read")) - screen->has_WGL_ARB_make_current_read = TRUE; - - if (strstr(wgl_extensions, "WGL_ARB_pbuffer")) - screen->has_WGL_ARB_pbuffer = TRUE; - - if (strstr(wgl_extensions, "WGL_ARB_multisample")) - screen->has_WGL_ARB_multisample = TRUE; - - if (strstr(wgl_extensions, "WGL_ARB_framebuffer_sRGB")) { - screen->has_WGL_ARB_framebuffer_sRGB = 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 - memset(&rejects, 0, sizeof(rejects)); - if (strstr(wgl_extensions, "WGL_ARB_pixel_format")) { - glxWinCreateConfigsExt(hdc, screen, &rejects); - - /* - 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) { - memset(&rejects, 0, sizeof(rejects)); - 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"); - goto error; - } - - /* These will be set by __glXScreenInit */ - screen->base.visuals = NULL; - screen->base.numVisuals = 0; - - __glXScreenInit(&screen->base, pScreen); - } - - wglMakeCurrent(NULL, NULL); - wglDeleteContext(hglrc); - ReleaseDC(hwnd, hdc); - DestroyWindow(hwnd); - - // dump out fbConfigs now fbConfigIds and visualIDs have been assigned - fbConfigsDump(screen->base.numFBConfigs, screen->base.fbconfigs, &rejects); - - /* Wrap RealizeWindow, UnrealizeWindow and CopyWindow on this screen */ - screen->RealizeWindow = pScreen->RealizeWindow; - pScreen->RealizeWindow = glxWinRealizeWindow; - screen->UnrealizeWindow = pScreen->UnrealizeWindow; - pScreen->UnrealizeWindow = glxWinUnrealizeWindow; - screen->CopyWindow = pScreen->CopyWindow; - pScreen->CopyWindow = glxWinCopyWindow; - - // Note that WGL is active on this screen - winSetScreenAiglxIsActive(pScreen); - - return &screen->base; - - error: - // Something went wrong and we can't use the native GL implementation - // so make sure the mesa GL implementation is selected instead - glWinSelectImplementation(0); - - return NULL; -} - -/* ---------------------------------------------------------------------- */ -/* - * Window functions - */ - -static Bool -glxWinRealizeWindow(WindowPtr pWin) -{ - Bool result; - ScreenPtr pScreen = pWin->drawable.pScreen; - glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen); - - GLWIN_DEBUG_MSG("glxWinRealizeWindow"); - - /* Allow the window to be created (RootlessRealizeWindow is inside our wrap) */ - pScreen->RealizeWindow = screenPriv->RealizeWindow; - result = pScreen->RealizeWindow(pWin); - pScreen->RealizeWindow = glxWinRealizeWindow; - - return result; -} - -static void -glxWinCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - __GLXWinDrawable *pGlxDraw; - ScreenPtr pScreen = pWindow->drawable.pScreen; - glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen); - - GLWIN_TRACE_MSG("glxWinCopyWindow pWindow %p", pWindow); - - dixLookupResourceByType((void *) &pGlxDraw, pWindow->drawable.id, - __glXDrawableRes, NullClient, DixUnknownAccess); - - /* - Discard any CopyWindow requests if a GL drawing context is pointing at the window - - 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 occurring, which will - cause those incorrect bits to be transferred to the display.... - */ - if (pGlxDraw && pGlxDraw->drawContext) { - GLWIN_DEBUG_MSG("glxWinCopyWindow: discarding"); - return; - } - - GLWIN_DEBUG_MSG("glxWinCopyWindow - passing to hw layer"); - - pScreen->CopyWindow = screenPriv->CopyWindow; - pScreen->CopyWindow(pWindow, ptOldOrg, prgnSrc); - pScreen->CopyWindow = glxWinCopyWindow; -} - -static Bool -glxWinUnrealizeWindow(WindowPtr pWin) -{ - Bool result; - ScreenPtr pScreen = pWin->drawable.pScreen; - glxWinScreen *screenPriv = (glxWinScreen *) glxGetScreen(pScreen); - - GLWIN_DEBUG_MSG("glxWinUnrealizeWindow"); - - pScreen->UnrealizeWindow = screenPriv->UnrealizeWindow; - result = pScreen->UnrealizeWindow(pWin); - pScreen->UnrealizeWindow = glxWinUnrealizeWindow; - - return result; -} - -/* ---------------------------------------------------------------------- */ -/* - * Drawable functions - */ - -static GLboolean -glxWinDrawableSwapBuffers(ClientPtr client, __GLXdrawable * base) -{ - HDC dc; - HWND hwnd; - BOOL ret; - __GLXWinDrawable *draw = (__GLXWinDrawable *) base; - - /* Swap buffers on the last active context for drawing on the drawable */ - 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); - - dc = glxWinMakeDC(draw->drawContext, draw, &dc, &hwnd); - if (dc == NULL) - return GL_FALSE; - - ret = wglSwapLayerBuffers(dc, WGL_SWAP_MAIN_PLANE); - - glxWinReleaseDC(hwnd, dc, draw); - - if (!ret) { - ErrorF("wglSwapBuffers failed: %s\n", glxWinErrorMessage()); - return GL_FALSE; - } - - return GL_TRUE; -} - -static void -glxWinDrawableCopySubBuffer(__GLXdrawable * drawable, - int x, int y, int w, int h) -{ - glAddSwapHintRectWINWrapper(x, y, w, h); - glxWinDrawableSwapBuffers(NULL, drawable); -} - -static void -glxWinDrawableDestroy(__GLXdrawable * base) -{ - __GLXWinDrawable *glxPriv = (__GLXWinDrawable *) base; - - 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 (!DeleteDC(glxPriv->dibDC)) { - ErrorF("DeleteDC failed: %s\n", glxWinErrorMessage()); - } - } - - if (glxPriv->hDIB) { - if (!CloseHandle(glxPriv->hSection)) { - ErrorF("CloseHandle failed: %s\n", glxWinErrorMessage()); - } - - if (!DeleteObject(glxPriv->hDIB)) { - ErrorF("DeleteObject failed: %s\n", glxWinErrorMessage()); - } - - ((PixmapPtr) glxPriv->base.pDraw)->devPrivate.ptr = glxPriv->pOldBits; - } - - GLWIN_DEBUG_MSG("glxWinDestroyDrawable"); - free(glxPriv); -} - -static __GLXdrawable * -glxWinCreateDrawable(ClientPtr client, - __GLXscreen * screen, - DrawablePtr pDraw, - XID drawId, int type, XID glxDrawId, __GLXconfig * conf) -{ - __GLXWinDrawable *glxPriv; - - glxPriv = malloc(sizeof *glxPriv); - - if (glxPriv == NULL) - return NULL; - - memset(glxPriv, 0, sizeof *glxPriv); - - if (!__glXDrawableInit - (&glxPriv->base, screen, pDraw, type, glxDrawId, conf)) { - free(glxPriv); - return NULL; - } - - glxPriv->base.destroy = 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); - - return &glxPriv->base; -} - -void -glxWinDeferredCreateDrawable(__GLXWinDrawable *draw, __GLXconfig *config) -{ - switch (draw->base.type) { - case GLX_DRAWABLE_WINDOW: - { - WindowPtr pWin = (WindowPtr) draw->base.pDraw; - - if (!(config->drawableType & GLX_WINDOW_BIT)) { - ErrorF - ("glxWinDeferredCreateDrawable: tried to create a GLX_DRAWABLE_WINDOW drawable with a fbConfig which doesn't have drawableType GLX_WINDOW_BIT\n"); - } - - if (pWin == NULL) { - GLWIN_DEBUG_MSG("Deferring until X window is created"); - return; - } - - GLWIN_DEBUG_MSG("glxWinDeferredCreateDrawable: pWin %p", pWin); - - if (winGetWindowInfo(pWin) == NULL) { - GLWIN_DEBUG_MSG("Deferring until native window is created"); - return; - } - } - break; - - case GLX_DRAWABLE_PBUFFER: - { - if (draw->hPbuffer == NULL) { - __GLXscreen *screen; - glxWinScreen *winScreen; - int pixelFormat; - - // XXX: which DC are we supposed to use??? - HDC screenDC = GetDC(NULL); - - if (!(config->drawableType & GLX_PBUFFER_BIT)) { - ErrorF - ("glxWinDeferredCreateDrawable: tried to create a GLX_DRAWABLE_PBUFFER drawable with a fbConfig which doesn't have drawableType GLX_PBUFFER_BIT\n"); - } - - screen = glxGetScreen(screenInfo.screens[draw->base.pDraw->pScreen->myNum]); - winScreen = (glxWinScreen *) screen; - - pixelFormat = - fbConfigToPixelFormatIndex(screenDC, config, - GLX_PBUFFER_BIT, winScreen); - if (pixelFormat == 0) { - return; - } - - draw->hPbuffer = - wglCreatePbufferARBWrapper(screenDC, pixelFormat, - draw->base.pDraw->width, - draw->base.pDraw->height, NULL); - ReleaseDC(NULL, screenDC); - - if (draw->hPbuffer == NULL) { - ErrorF("wglCreatePbufferARBWrapper error: %s\n", - glxWinErrorMessage()); - return; - } - - GLWIN_DEBUG_MSG - ("glxWinDeferredCreateDrawable: pBuffer %p created for drawable %p", - draw->hPbuffer, draw); - } - } - break; - - case GLX_DRAWABLE_PIXMAP: - { - if (draw->dibDC == NULL) { - BITMAPINFOHEADER bmpHeader; - void *pBits; - __GLXscreen *screen; - DWORD size; - char name[MAX_PATH]; - - 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 (!(config->drawableType & GLX_PIXMAP_BIT)) { - ErrorF - ("glxWinDeferredCreateDrawable: tried to create a GLX_DRAWABLE_PIXMAP drawable with a fbConfig which doesn't have drawableType GLX_PIXMAP_BIT\n"); - } - - draw->dibDC = CreateCompatibleDC(NULL); - if (draw->dibDC == NULL) { - ErrorF("CreateCompatibleDC error: %s\n", glxWinErrorMessage()); - return; - } - -#define RASTERWIDTHBYTES(bmi) (((((bmi)->biWidth*(bmi)->biBitCount)+31)&~31)>>3) - size = bmpHeader.biHeight * RASTERWIDTHBYTES(&bmpHeader); - GLWIN_DEBUG_MSG("shared memory region size %zu + %u\n", sizeof(BITMAPINFOHEADER), (unsigned int)size); - - // Create unique name for mapping based on XID - // - // XXX: not quite unique as potentially this name could be used in - // another server instance. Not sure how to deal with that. - snprintf(name, sizeof(name), "Local\\CYGWINX_WINDOWSDRI_%08x", (unsigned int)draw->base.pDraw->id); - GLWIN_DEBUG_MSG("shared memory region name %s\n", name); - - // Create a file mapping backed by the pagefile - draw->hSection = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, 0, sizeof(BITMAPINFOHEADER) + size, name); - if (draw->hSection == NULL) { - ErrorF("CreateFileMapping error: %s\n", glxWinErrorMessage()); - return; - } - - draw->hDIB = - CreateDIBSection(draw->dibDC, (BITMAPINFO *) &bmpHeader, - DIB_RGB_COLORS, &pBits, draw->hSection, sizeof(BITMAPINFOHEADER)); - if (draw->dibDC == NULL) { - ErrorF("CreateDIBSection error: %s\n", glxWinErrorMessage()); - return; - } - - // Store a copy of the BITMAPINFOHEADER at the start of the shared - // memory for the information of the receiving process - { - LPVOID pData = MapViewOfFile(draw->hSection, FILE_MAP_WRITE, 0, 0, 0); - memcpy(pData, (void *)&bmpHeader, sizeof(BITMAPINFOHEADER)); - UnmapViewOfFile(pData); - } - - // 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; - - // Select the DIB into the DC - draw->hOldDIB = SelectObject(draw->dibDC, draw->hDIB); - if (!draw->hOldDIB) { - ErrorF("SelectObject error: %s\n", glxWinErrorMessage()); - } - - screen = glxGetScreen(screenInfo.screens[draw->base.pDraw->pScreen->myNum]); - - // Set the pixel format of the bitmap - glxWinSetPixelFormat(draw->dibDC, - draw->base.pDraw->bitsPerPixel, - GLX_PIXMAP_BIT, - screen, - config); - - GLWIN_DEBUG_MSG - ("glxWinDeferredCreateDrawable: DIB bitmap %p created for drawable %p", - draw->hDIB, draw); - } - } - break; - - default: - { - ErrorF - ("glxWinDeferredCreateDrawable: tried to attach unhandled drawable type %d\n", - draw->base.type); - return; - } - } -} - -/* ---------------------------------------------------------------------- */ -/* - * Texture functions - */ - -static - int -glxWinBindTexImage(__GLXcontext * baseContext, - int buffer, __GLXdrawable * pixmap) -{ - ErrorF("glxWinBindTexImage: not implemented\n"); - return FALSE; -} - -static - int -glxWinReleaseTexImage(__GLXcontext * baseContext, - int buffer, __GLXdrawable * pixmap) -{ - ErrorF(" glxWinReleaseTexImage: not implemented\n"); - return FALSE; -} - -/* ---------------------------------------------------------------------- */ -/* - * Lazy update context implementation - * - * WGL contexts are created for a specific HDC, so we cannot create the WGL - * context in glxWinCreateContext(), we must defer creation until the context - * is actually used on a specific drawable which is connected to a native window, - * pbuffer or DIB - * - * The WGL context may be used on other, compatible HDCs, so we don't need to - * recreate it for every new native window - * - * XXX: I wonder why we can't create the WGL context on the screen HDC ? - * Basically we assume all HDCs are compatible at the moment: if they are not - * we are in a muddle, there was some code in the old implementation to attempt - * to transparently migrate a context to a new DC by copying state and sharing - * lists with the old one... - */ - -static Bool -glxWinSetPixelFormat(HDC hdc, int bppOverride, int drawableTypeOverride, - __GLXscreen *screen, __GLXconfig *config) -{ - glxWinScreen *winScreen = (glxWinScreen *) screen; - GLXWinConfig *winConfig = (GLXWinConfig *) config; - - 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 - */ - - if (! - ((bppOverride && - (bppOverride != - (config->redBits + config->greenBits + config->blueBits))) - || ((config->drawableType & drawableTypeOverride) == 0))) { - if (!SetPixelFormat(hdc, winConfig->pixelFormatIndex, NULL)) { - ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); - return FALSE; - } - - return TRUE; - } - - /* - 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 - 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 - 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) - - pixmap rendering is always slow for us, so we don't want to choose those visuals - 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) { - int pixelFormat = - fbConfigToPixelFormatIndex(hdc, config, - drawableTypeOverride, winScreen); - if (pixelFormat != 0) { - GLWIN_DEBUG_MSG("wglChoosePixelFormat: chose pixelFormatIndex %d", - pixelFormat); - ErrorF - ("wglChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n", - pixelFormat, winConfig->pixelFormatIndex); - - if (!SetPixelFormat(hdc, pixelFormat, NULL)) { - ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); - return FALSE; - } - } - } - - /* - For some drivers, wglChoosePixelFormatARB() can fail when the provided - DC doesn't belong to the driver (e.g. it's a compatible DC for a bitmap, - so allow fallback to ChoosePixelFormat() - */ - { - PIXELFORMATDESCRIPTOR pfd; - int pixelFormat; - - /* convert fbConfig to PFD */ - if (fbConfigToPixelFormat(config, &pfd, drawableTypeOverride)) { - ErrorF("glxWinSetPixelFormat: fbConfigToPixelFormat failed\n"); - return FALSE; - } - - if (glxWinDebugSettings.dumpPFD) - pfdOut(&pfd); - - 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; - } - - GLWIN_DEBUG_MSG("ChoosePixelFormat: chose pixelFormatIndex %d", - pixelFormat); - ErrorF - ("ChoosePixelFormat: chose pixelFormatIndex %d (rather than %d as originally planned)\n", - pixelFormat, winConfig->pixelFormatIndex); - - if (!SetPixelFormat(hdc, pixelFormat, &pfd)) { - ErrorF("SetPixelFormat error: %s\n", glxWinErrorMessage()); - return FALSE; - } - } - - return TRUE; -} - -static HDC -glxWinMakeDC(__GLXWinContext * gc, __GLXWinDrawable * draw, HDC * hdc, - HWND * hwnd) -{ - *hdc = NULL; - *hwnd = NULL; - - if (draw == NULL) { - GLWIN_TRACE_MSG("No drawable for context %p (native ctx %p)", gc, - gc->ctx); - return NULL; - } - - switch (draw->base.type) { - case GLX_DRAWABLE_WINDOW: - { - WindowPtr pWin; - - pWin = (WindowPtr) draw->base.pDraw; - if (pWin == NULL) { - GLWIN_TRACE_MSG("for drawable %p, no WindowPtr", pWin); - return NULL; - } - - *hwnd = winGetWindowInfo(pWin); - - if (*hwnd == NULL) { - ErrorF("No HWND error: %s\n", glxWinErrorMessage()); - return NULL; - } - - *hdc = GetDC(*hwnd); - - if (*hdc == NULL) - ErrorF("GetDC error: %s\n", glxWinErrorMessage()); - - /* Check if the hwnd has changed... */ - if (*hwnd != gc->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); - gc->hwnd = *hwnd; - - /* We must select a pixelformat, but SetPixelFormat can only be called once for a window... */ - if (!glxWinSetPixelFormat(*hdc, 0, GLX_WINDOW_BIT, gc->base.pGlxScreen, gc->base.config)) { - ErrorF("glxWinSetPixelFormat error: %s\n", - glxWinErrorMessage()); - ReleaseDC(*hwnd, *hdc); - *hdc = NULL; - return NULL; - } - } - } - break; - - case GLX_DRAWABLE_PBUFFER: - { - *hdc = wglGetPbufferDCARBWrapper(draw->hPbuffer); - - if (*hdc == NULL) - ErrorF("GetDC (pbuffer) error: %s\n", glxWinErrorMessage()); - } - break; - - case GLX_DRAWABLE_PIXMAP: - { - *hdc = draw->dibDC; - } - break; - - default: - { - ErrorF("glxWinMakeDC: tried to makeDC for unhandled drawable type %d\n", - draw->base.type); - } - } - - if (glxWinDebugSettings.dumpDC) - GLWIN_DEBUG_MSG("Got HDC %p", *hdc); - - return *hdc; -} - -static void -glxWinReleaseDC(HWND hwnd, HDC hdc, __GLXWinDrawable * draw) -{ - switch (draw->base.type) { - case GLX_DRAWABLE_WINDOW: - { - ReleaseDC(hwnd, hdc); - } - break; - - case GLX_DRAWABLE_PBUFFER: - { - if (!wglReleasePbufferDCARBWrapper(draw->hPbuffer, hdc)) { - ErrorF("wglReleasePbufferDCARB error: %s\n", glxWinErrorMessage()); - } - } - break; - - case GLX_DRAWABLE_PIXMAP: - { - // 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(); - } - break; - - default: - { - ErrorF - ("glxWinReleaseDC: tried to releaseDC for unhandled drawable type %d\n", - draw->base.type); - } - } -} - -static void -glxWinDeferredCreateContext(__GLXWinContext * gc, __GLXWinDrawable * draw) -{ - HDC dc; - HWND hwnd; - - GLWIN_DEBUG_MSG - ("glxWinDeferredCreateContext: attach context %p to drawable %p", gc, - draw); - - glxWinDeferredCreateDrawable(draw, gc->base.config); - - dc = glxWinMakeDC(gc, draw, &dc, &hwnd); - gc->ctx = wglCreateContext(dc); - glxWinReleaseDC(hwnd, dc, draw); - - if (gc->ctx == NULL) { - ErrorF("wglCreateContext error: %s\n", glxWinErrorMessage()); - return; - } - - 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) { - 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()); - } - } -} - -/* ---------------------------------------------------------------------- */ -/* - * Context functions - */ - -/* Context manipulation routines should return TRUE on success, FALSE on failure */ -static int -glxWinContextMakeCurrent(__GLXcontext * base) -{ - __GLXWinContext *gc = (__GLXWinContext *) base; - glxWinScreen *scr = (glxWinScreen *)base->pGlxScreen; - BOOL ret; - HDC drawDC; - HDC readDC = NULL; - __GLXdrawable *drawPriv; - __GLXdrawable *readPriv = NULL; - HWND hDrawWnd; - HWND hReadWnd; - - GLWIN_TRACE_MSG("glxWinContextMakeCurrent context %p (native ctx %p)", gc, - gc->ctx); - - /* Keep a note of the last active context in the drawable */ - drawPriv = gc->base.drawPriv; - ((__GLXWinDrawable *) drawPriv)->drawContext = gc; - - if (gc->ctx == NULL) { - glxWinDeferredCreateContext(gc, (__GLXWinDrawable *) drawPriv); - } - - if (gc->ctx == NULL) { - ErrorF("glxWinContextMakeCurrent: Native context is NULL\n"); - return FALSE; - } - - drawDC = - glxWinMakeDC(gc, (__GLXWinDrawable *) drawPriv, &drawDC, &hDrawWnd); - if (drawDC == NULL) { - ErrorF("glxWinMakeDC failed for drawDC\n"); - return FALSE; - } - - if ((gc->base.readPriv != NULL) && (gc->base.readPriv != gc->base.drawPriv)) { - /* - * We enable GLX_SGI_make_current_read unconditionally, but the - * renderer might not support it. It's fairly rare to use this - * feature so just error out if it can't work. - */ - if (!scr->has_WGL_ARB_make_current_read) - return FALSE; - - /* - 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 - */ - readPriv = gc->base.readPriv; - readDC = - glxWinMakeDC(gc, (__GLXWinDrawable *) readPriv, &readDC, &hReadWnd); - if (readDC == NULL) { - ErrorF("glxWinMakeDC failed for readDC\n"); - glxWinReleaseDC(hDrawWnd, drawDC, (__GLXWinDrawable *) drawPriv); - return FALSE; - } - - ret = wglMakeContextCurrentARBWrapper(drawDC, readDC, gc->ctx); - if (!ret) { - ErrorF("wglMakeContextCurrentARBWrapper error: %s\n", - glxWinErrorMessage()); - } - } - else { - /* Otherwise, just use wglMakeCurrent */ - ret = wglMakeCurrent(drawDC, gc->ctx); - if (!ret) { - ErrorF("wglMakeCurrent error: %s\n", glxWinErrorMessage()); - } - } - - // 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... - - glxWinReleaseDC(hDrawWnd, drawDC, (__GLXWinDrawable *) drawPriv); - if (readDC) - glxWinReleaseDC(hReadWnd, readDC, (__GLXWinDrawable *) readPriv); - - return ret; -} - -static int -glxWinContextLoseCurrent(__GLXcontext * base) -{ - BOOL ret; - __GLXWinContext *gc = (__GLXWinContext *) base; - - GLWIN_TRACE_MSG("glxWinContextLoseCurrent context %p (native ctx %p)", gc, - gc->ctx); - - /* - An error seems to be reported if we try to make no context current - if there is already no current context, so avoid doing that... - */ - if (wglGetCurrentContext() != NULL) { - ret = wglMakeCurrent(NULL, NULL); /* We don't need a DC when setting no current context */ - if (!ret) - ErrorF("glxWinContextLoseCurrent error: %s\n", - glxWinErrorMessage()); - } - - return TRUE; -} - -static int -glxWinContextCopy(__GLXcontext * dst_base, __GLXcontext * src_base, - unsigned long mask) -{ - __GLXWinContext *dst = (__GLXWinContext *) dst_base; - __GLXWinContext *src = (__GLXWinContext *) src_base; - BOOL ret; - - GLWIN_DEBUG_MSG("glxWinContextCopy"); - - ret = wglCopyContext(src->ctx, dst->ctx, mask); - if (!ret) { - ErrorF("wglCopyContext error: %s\n", glxWinErrorMessage()); - } - - return ret; -} - -static void -glxWinContextDestroy(__GLXcontext * base) -{ - __GLXWinContext *gc = (__GLXWinContext *) base; - - if (gc != NULL) { - GLWIN_DEBUG_MSG("GLXcontext %p destroyed (native ctx %p)", base, - gc->ctx); - - if (gc->ctx) { - /* It's bad style to delete the context while it's still current */ - if (wglGetCurrentContext() == gc->ctx) { - wglMakeCurrent(NULL, NULL); - } - - { - BOOL ret = wglDeleteContext(gc->ctx); - - if (!ret) - ErrorF("wglDeleteContext error: %s\n", - glxWinErrorMessage()); - } - - gc->ctx = NULL; - } - - free(gc); - } -} - -static __GLXcontext * -glxWinCreateContext(__GLXscreen * screen, - __GLXconfig * modes, __GLXcontext * baseShareContext, - unsigned num_attribs, const uint32_t * attribs, int *error) -{ - __GLXWinContext *context; - __GLXWinContext *shareContext = (__GLXWinContext *) baseShareContext; - - context = 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.bindTexImage = glxWinBindTexImage; - context->base.releaseTexImage = glxWinReleaseTexImage; - context->base.config = modes; - context->base.pGlxScreen = screen; - - // actual native GL context creation is deferred until attach() - context->ctx = NULL; - context->shareContext = shareContext; - - GLWIN_DEBUG_MSG("GLXcontext %p created", context); - - return &(context->base); -} - -/* ---------------------------------------------------------------------- */ -/* - * Utility functions - */ - -static int -GetShift(int mask) -{ - int shift = 0; - while (mask > 1) { - shift++; - mask >>=1; - } - return shift; -} - -static int -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 */ - }; - - if ((mode->drawableType | drawableTypeOverride) & GLX_WINDOW_BIT) - 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 */ - - if (mode->stereoMode) { - pfd.dwFlags |= PFD_STEREO; - } - if (mode->doubleBufferMode) { - pfd.dwFlags |= PFD_DOUBLEBUFFER; - } - - pfd.cColorBits = mode->redBits + mode->greenBits + mode->blueBits; - pfd.cRedBits = mode->redBits; - pfd.cRedShift = GetShift(mode->redMask); - pfd.cGreenBits = mode->greenBits; - pfd.cGreenShift = GetShift(mode->greenMask); - pfd.cBlueBits = mode->blueBits; - pfd.cBlueShift = GetShift(mode->blueMask); - pfd.cAlphaBits = mode->alphaBits; - pfd.cAlphaShift = GetShift(mode->alphaMask); - - if (mode->visualType == GLX_TRUE_COLOR) { - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.dwVisibleMask = - (pfd.cRedBits << pfd.cRedShift) | (pfd.cGreenBits << pfd.cGreenShift) | - (pfd.cBlueBits << pfd.cBlueShift) | (pfd.cAlphaBits << pfd.cAlphaShift); - } - else { - pfd.iPixelType = PFD_TYPE_COLORINDEX; - pfd.dwVisibleMask = mode->transparentIndex; - } - - pfd.cAccumBits = - mode->accumRedBits + mode->accumGreenBits + mode->accumBlueBits + - mode->accumAlphaBits; - pfd.cAccumRedBits = mode->accumRedBits; - pfd.cAccumGreenBits = mode->accumGreenBits; - pfd.cAccumBlueBits = mode->accumBlueBits; - pfd.cAccumAlphaBits = mode->accumAlphaBits; - - pfd.cDepthBits = mode->depthBits; - pfd.cStencilBits = mode->stencilBits; - pfd.cAuxBuffers = mode->numAuxBuffers; - - /* mode->level ? */ - - *pfdret = pfd; - - return 0; -} - -#define SET_ATTR_VALUE(attr, value) { attribList[i++] = attr; attribList[i++] = value; assert(i < ARRAY_SIZE(attribList)); } - -static int -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); - - switch (mode->renderType) - { - case GLX_COLOR_INDEX_BIT: - case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT: - SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_COLORINDEX_ARB); - SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->indexBits); - break; - - default: - ErrorF("unexpected renderType %x\n", mode->renderType); - /* fall-through */ - case GLX_RGBA_BIT: - SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB); - SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); - break; - - case GLX_RGBA_FLOAT_BIT_ARB: - SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ARB); - SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); - break; - - case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT: - SET_ATTR_VALUE(WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT); - SET_ATTR_VALUE(WGL_COLOR_BITS_ARB, mode->rgbBits); - break; - } - - 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_METHOD_ARB, WGL_SWAP_COPY_ARB); - - // 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); - - if (winScreen->has_WGL_ARB_multisample) { - SET_ATTR_VALUE(WGL_SAMPLE_BUFFERS_ARB, mode->sampleBuffers); - SET_ATTR_VALUE(WGL_SAMPLES_ARB, mode->samples); - } - - // 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); - } - 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 (winScreen->has_WGL_ARB_framebuffer_sRGB) - SET_ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, TRUE); - - SET_ATTR_VALUE(0, 0); // terminator - - /* 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"); - } - } - - return 0; -} - -/* ---------------------------------------------------------------------- */ - -#define BITS_AND_SHIFT_TO_MASK(bits,mask) (((1<<(bits))-1) << (mask)) - -// -// Create the GLXconfigs using DescribePixelFormat() -// -static void -glxWinCreateConfigs(HDC hdc, glxWinScreen * screen) -{ - GLXWinConfig *first = NULL, *prev = NULL; - int numConfigs = 0; - int i = 0; - int n = 0; - PIXELFORMATDESCRIPTOR pfd; - - GLWIN_DEBUG_MSG("glxWinCreateConfigs"); - - screen->base.numFBConfigs = 0; - screen->base.fbconfigs = NULL; - - // get the number of pixelformats - numConfigs = - DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL); - LogMessage(X_INFO, "%d pixel formats reported by DescribePixelFormat\n", - numConfigs); - - n = 0; - - /* fill in configs */ - for (i = 0; i < numConfigs; i++) { - int rc; - GLXWinConfig temp; - GLXWinConfig *c = &temp; - GLXWinConfig *work; - memset(c, 0, sizeof(GLXWinConfig)); - - c->pixelFormatIndex = i + 1; - - rc = DescribePixelFormat(hdc, i + 1, sizeof(PIXELFORMATDESCRIPTOR), - &pfd); - - if (!rc) { - ErrorF("DescribePixelFormat failed for index %d, error %s\n", i + 1, - glxWinErrorMessage()); - break; - } - - if (glxWinDebugSettings.dumpPFD) - pfdOut(&pfd); - - 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%08x, skipping", i + 1, - (unsigned int)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.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.rgbBits = pfd.cColorBits; - - if (pfd.iPixelType == PFD_TYPE_COLORINDEX) { - c->base.indexBits = pfd.cColorBits; - } - 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.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 - - 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; - GLWIN_DEBUG_MSG("pixelFormat %d is un-accelerated, skipping", i + 1); - continue; - } - else { - // PFD_GENERIC_ACCELERATED is not considered, so this may be MCD or ICD accelerated... - c->base.visualRating = GLX_NONE_EXT; - } - - /* 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; - c->base.transparentAlpha = GLX_NONE; - c->base.transparentIndex = pfd.dwVisibleMask; - c->base.transparentPixel = GLX_TRANSPARENT_INDEX; - } - else { - c->base.visualType = GLX_TRUE_COLOR; - c->base.transparentRed = - (pfd.dwVisibleMask & c->base.redMask) >> pfd.cRedShift; - c->base.transparentGreen = - (pfd.dwVisibleMask & c->base.greenMask) >> pfd.cGreenShift; - c->base.transparentBlue = - (pfd.dwVisibleMask & c->base.blueMask) >> pfd.cBlueShift; - c->base.transparentAlpha = - (pfd.dwVisibleMask & c->base.alphaMask) >> pfd.cAlphaShift; - c->base.transparentIndex = GLX_NONE; - c->base.transparentPixel = GLX_TRANSPARENT_RGB; - } - - /* 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)); - - if (pfd.iPixelType == PFD_TYPE_COLORINDEX) { - c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT; - } - else { - c->base.renderType = GLX_RGBA_BIT; - } - - 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_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; - - case PFD_GENERIC_ACCELERATED: - c->base.visualSelectGroup = 1; - break; - - case PFD_GENERIC_FORMAT: - c->base.visualSelectGroup = 0; - break; - - default: - ; - // "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; - - /* EXT_texture_from_pixmap */ - c->base.bindToTextureRgb = -1; - c->base.bindToTextureRgba = -1; - c->base.bindToMipmapTexture = -1; - c->base.bindToTextureTargets = -1; - c->base.yInverted = -1; - c->base.sRGBCapable = 0; - - n++; - - // allocate and save - work = malloc(sizeof(GLXWinConfig)); - if (NULL == work) { - ErrorF("Failed to allocate GLXWinConfig\n"); - break; - } - *work = temp; - - // note the first config - if (!first) - first = work; - - // update previous config to point to this config - if (prev) - prev->base.next = &(work->base); - prev = work; - } - - GLWIN_DEBUG_MSG - ("found %d pixelFormats suitable for conversion to fbConfigs", n); - - screen->base.numFBConfigs = n; - screen->base.fbconfigs = first ? &(first->base) : NULL; -} - -// 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) -{ - 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; -} - -// -// Create the GLXconfigs using wglGetPixelFormatAttribfvARB() extension -// -static void -glxWinCreateConfigsExt(HDC hdc, glxWinScreen * screen, PixelFormatRejectStats * rejects) -{ - GLXWinConfig *first = NULL, *prev = NULL; - int i = 0; - int n = 0; - - const int attr = WGL_NUMBER_PIXEL_FORMATS_ARB; - int numConfigs; - - int attrs[50]; - unsigned int num_attrs = 0; - - GLWIN_DEBUG_MSG("glxWinCreateConfigsExt"); - - 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; - } - - LogMessage(X_INFO, - "%d pixel formats reported by wglGetPixelFormatAttribivARB\n", - numConfigs); - - n = 0; - -#define ADD_ATTR(a) { attrs[num_attrs++] = a; assert(num_attrs < ARRAY_SIZE(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); - } - - 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_framebuffer_sRGB) { - // we may not query these attrs if WGL_ARB_framebuffer_sRGB is not offered - ADD_ATTR(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB); - } - - /* fill in configs */ - for (i = 0; i < numConfigs; i++) { - int values[num_attrs]; - GLXWinConfig temp; - GLXWinConfig *c = &temp; - GLXWinConfig *work; - memset(c, 0, sizeof(GLXWinConfig)); - - 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; - } - -#define ATTR_VALUE(a, d) getAttrValue(attrs, values, num_attrs, (a), (d)) - - if (!ATTR_VALUE(WGL_SUPPORT_OPENGL_ARB, 0)) { - rejects->notOpenGL++; - 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)) { - 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; - c->base.renderType = GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT; - - /* - Assume RGBA rendering is available on all single-channel 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 - */ - - break; - - 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; - c->base.renderType = GLX_RGBA_BIT; - break; - - case WGL_TYPE_RGBA_FLOAT_ARB: - c->base.indexBits = 0; - c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); - c->base.visualType = GLX_TRUE_COLOR; - c->base.renderType = GLX_RGBA_FLOAT_BIT_ARB; - // assert pbuffer drawable - // assert WGL_ARB_pixel_format_float - break; - - case WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT: - c->base.indexBits = 0; - c->base.rgbBits = ATTR_VALUE(WGL_COLOR_BITS_ARB, 0); - c->base.visualType = GLX_TRUE_COLOR; - c->base.renderType = GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT; - // assert pbuffer drawable - // assert WGL_EXT_pixel_format_packed_float - break; - - default: - rejects->unknownPixelType++; - 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); - - { - 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\n", - 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.visualID = -1; // will be set by __glXScreenInit() - - /* 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)); - - case WGL_NO_ACCELERATION_ARB: - rejects->unaccelerated++; - c->base.visualRating = GLX_SLOW_VISUAL_EXT; - GLWIN_DEBUG_MSG("pixelFormat %d is un-accelerated, skipping", i + 1); - continue; - break; - - case WGL_GENERIC_ACCELERATION_ARB: - case WGL_FULL_ACCELERATION_ARB: - 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); - } - 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); - } - 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)); - - 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); - } - 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; - - /* 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; - - case WGL_GENERIC_ACCELERATION_ARB: - c->base.visualSelectGroup = 1; - break; - - default: - case WGL_NO_ACCELERATION_ARB: - c->base.visualSelectGroup = 0; - break; - } - - /* OML_swap_method */ - switch (ATTR_VALUE(WGL_SWAP_METHOD_ARB, 0)) { - case WGL_SWAP_EXCHANGE_ARB: - c->base.swapMethod = GLX_SWAP_EXCHANGE_OML; - break; - - case WGL_SWAP_COPY_ARB: - 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)); - - case WGL_SWAP_UNDEFINED_ARB: - c->base.swapMethod = GLX_SWAP_UNDEFINED_OML; - } - - /* 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; - } - 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; - - /* WGL_ARB_framebuffer_sRGB */ - if (screen->has_WGL_ARB_framebuffer_sRGB) - c->base.sRGBCapable = ATTR_VALUE(WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB, 0); - else - c->base.sRGBCapable = 0; - - n++; - - // allocate and save - work = malloc(sizeof(GLXWinConfig)); - if (NULL == work) { - ErrorF("Failed to allocate GLXWinConfig\n"); - break; - } - *work = temp; - - // note the first config - if (!first) - first = work; - - // update previous config to point to this config - if (prev) - prev->base.next = &(work->base); - prev = work; - } - - screen->base.numFBConfigs = n; - screen->base.fbconfigs = first ? &(first->base) : NULL; -} diff --git a/hw/xwin/glx/indirect.h b/hw/xwin/glx/indirect.h deleted file mode 100644 index c32ce7894..000000000 --- a/hw/xwin/glx/indirect.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright © 2014 Jon TURNEY - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef indirect_h -#define indirect_h - -#include <X11/Xwindows.h> -#include <GL/wglext.h> -#include <glx/extension_string.h> - -/* ---------------------------------------------------------------------- */ -/* - * structure definitions - */ - -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 */ - __GLXWinContext *shareContext; /* Context with which we will share display lists and textures */ - HWND hwnd; /* For detecting when HWND has changed */ -}; - -struct __GLXWinDrawable { - __GLXdrawable base; - __GLXWinContext *drawContext; - __GLXWinContext *readContext; - - /* If this drawable is GLX_DRAWABLE_PBUFFER */ - HPBUFFERARB hPbuffer; - - /* If this drawable is GLX_DRAWABLE_PIXMAP */ - HDC dibDC; - HANDLE hSection; /* file mapping handle */ - HBITMAP hDIB; - HBITMAP hOldDIB; /* original DIB for DC */ - void *pOldBits; /* original pBits for this drawable's pixmap */ -}; - -struct __GLXWinScreen { - __GLXscreen base; - - 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_make_current_read; - Bool has_WGL_ARB_framebuffer_sRGB; - - /* wrapped screen functions */ - RealizeWindowProcPtr RealizeWindow; - UnrealizeWindowProcPtr UnrealizeWindow; - CopyWindowProcPtr CopyWindow; -}; - -struct __GLXWinConfig { - __GLXconfig base; - int pixelFormatIndex; -}; - -/* ---------------------------------------------------------------------- */ -/* - * function prototypes - */ - -void -glxWinDeferredCreateDrawable(__GLXWinDrawable *draw, __GLXconfig *config); - -#endif /* indirect_h */ diff --git a/hw/xwin/glx/meson.build b/hw/xwin/glx/meson.build deleted file mode 100644 index 95f248953..000000000 --- a/hw/xwin/glx/meson.build +++ /dev/null @@ -1,102 +0,0 @@ -python3 = import('python3') - -# XWin requires OpenGL spec files in order to generate wrapper code for native GL functions -py3 = python3.find_python() -if run_command(py3, '-c', 'import lxml;').returncode() != 0 - error('python3 lxml module not found') -endif - -khronos_spec_dir = dependency('khronos-opengl-registry').get_pkgconfig_variable('specdir') - -gen_gl_wrappers_opts= ['-nodebug'] -gen_gl_wrappers_cmd = ['env', 'PYTHONPATH=' + khronos_spec_dir, py3, files('./gen_gl_wrappers.py'), gen_gl_wrappers_opts] - -wgl_wrappers = custom_target( - 'gen_wgl_wrappers', - command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-prefix', 'wgl', '-wrapper', '-preresolve', '-outfile', '@OUTPUT@'], - input: join_paths(khronos_spec_dir, 'wgl.xml'), - output: 'generated_wgl_wrappers.ic', - depend_files: join_paths(khronos_spec_dir, 'reg.py'), -) - -gl_shim = custom_target( - 'gen_gl_shim', - command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-shim', '-outfile', '@OUTPUT@'], - input: join_paths(khronos_spec_dir, 'gl.xml'), - output: 'generated_gl_shim.ic', - depend_files: join_paths(khronos_spec_dir, 'reg.py'), -) - -gl_thunks = custom_target( - 'gen_gl_thunks', - command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-thunk', '-outfile', '@OUTPUT@'], - input: join_paths(khronos_spec_dir, 'gl.xml'), - output: 'generated_gl_thunks.ic', - depend_files: join_paths(khronos_spec_dir, 'reg.py'), -) - -gl_thunks_def = custom_target( - 'gen_gl_thunks_def', - command: [gen_gl_wrappers_cmd, '-registry', '@INPUT@', '-thunkdefs', '-outfile', '@OUTPUT@'], - input: join_paths(khronos_spec_dir, 'gl.xml'), - output: 'generated_gl_thunks.def', - depend_files: join_paths(khronos_spec_dir, 'reg.py'), -) - -srcs_windows_glx = [ - 'winpriv.c', - 'winpriv.h', - 'glwindows.h', - 'glshim.c', - gl_shim, - 'indirect.c', - 'indirect.h', - 'wgl_ext_api.c', - wgl_wrappers, - 'wgl_ext_api.h', -] - -if build_windowsdri - srcs_windows_glx += [ - 'dri_helpers.c', - 'dri_helpers.h', - ] -endif - -xwin_glx_c_args = [] -xwin_glx_c_args += '-DHAVE_XWIN_CONFIG_H' -xwin_glx_c_args += '-DXWIN_GLX_WINDOWS' - -xwin_glx = static_library( - 'XwinGLX', - srcs_windows_glx, - include_directories: [ - inc, - top_dir_inc, - include_directories('../'), - ], - dependencies: common_dep, - c_args: xwin_glx_c_args, -) - -srcs_wgl_thunk = [ - 'glthunk.c', - gl_thunks, -] - -WGLthunk = shared_library( - 'nativeGLthunk', - srcs_wgl_thunk, - include_directories: [ - inc, - top_dir_inc, - ], - c_args: xwin_glx_c_args + [ - '-Wno-unused-function', - '-Wno-missing-prototypes', - '-Wno-missing-declarations', - ], - link_args: ['-lopengl32'], - vs_module_defs: gl_thunks_def, - install: true, -) diff --git a/hw/xwin/glx/wgl_ext_api.c b/hw/xwin/glx/wgl_ext_api.c deleted file mode 100644 index 61cfe8003..000000000 --- a/hw/xwin/glx/wgl_ext_api.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * File: wgl_ext_api.c - * 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. - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <X11/Xwindows.h> -#include <GL/gl.h> -#include <GL/glext.h> -#include <glx/glxserver.h> -#include <glx/glxext.h> -#include <GL/wglext.h> -#include <wgl_ext_api.h> -#include "glwindows.h" - -#define RESOLVE_DECL(type) \ - static type type##proc = NULL; - -#define PRERESOLVE(type, symbol) \ - type##proc = (type)wglGetProcAddress(symbol); - -#define RESOLVE_RET(type, symbol, retval) \ - if (type##proc == NULL) { \ - ErrorF("wglwrap: Can't resolve \"%s\"\n", symbol); \ - __glXErrorCallBack(0); \ - return retval; \ - } - -#define RESOLVE(procname, symbol) RESOLVE_RET(procname, symbol,) - -#define RESOLVED_PROC(type) type##proc - -/* - * Include generated cdecl wrappers for stdcall WGL functions - * - * There are extensions to the wgl*() API as well; again we call - * these functions by using wglGetProcAddress() to get a pointer - * to the function, and wrapping it for cdecl/stdcall conversion - * - * We arrange to resolve the functions up front, as they need a - * context to work, as we like to use them to be able to select - * a context. Again, this assumption fails badly on multimontor - * systems... - */ - -#include "generated_wgl_wrappers.ic" diff --git a/hw/xwin/glx/wgl_ext_api.h b/hw/xwin/glx/wgl_ext_api.h deleted file mode 100644 index b7231eb13..000000000 --- a/hw/xwin/glx/wgl_ext_api.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 <GL/wglext.h> - -void wglResolveExtensionProcs(void); - -/* - Prototypes for wrapper functions we actually use - XXX: should be automatically generated as well -*/ - -const char *wglGetExtensionsStringARBWrapper(HDC hdc); -BOOL wglMakeContextCurrentARBWrapper(HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -HDC wglGetCurrentReadDCARBWrapper(VOID); - -BOOL wglGetPixelFormatAttribivARBWrapper(HDC hdc, - int iPixelFormat, - int iLayerPlane, - UINT nAttributes, - const int *piAttributes, - int *piValues); - -BOOL wglGetPixelFormatAttribfvARBWrapper(HDC hdc, - int iPixelFormat, - int iLayerPlane, - UINT nAttributes, - const int *piAttributes, - FLOAT * pfValues); - -BOOL wglChoosePixelFormatARBWrapper(HDC hdc, - const int *piAttribIList, - const FLOAT * pfAttribFList, - UINT nMaxFormats, - int *piFormats, UINT * nNumFormats); - -HPBUFFERARB wglCreatePbufferARBWrapper(HDC hDC, - int iPixelFormat, - int iWidth, - int iHeight, const int *piAttribList); - -HDC wglGetPbufferDCARBWrapper(HPBUFFERARB hPbuffer); - -int wglReleasePbufferDCARBWrapper(HPBUFFERARB hPbuffer, HDC hDC); - -BOOL wglDestroyPbufferARBWrapper(HPBUFFERARB hPbuffer); - -BOOL wglQueryPbufferARBWrapper(HPBUFFERARB hPbuffer, - int iAttribute, int *piValue); - -BOOL wglSwapIntervalEXTWrapper(int interval); - -int wglGetSwapIntervalEXTWrapper(void); - -#endif /* wgl_ext_api_h */ diff --git a/hw/xwin/glx/winpriv.c b/hw/xwin/glx/winpriv.c deleted file mode 100644 index d72c04786..000000000 --- a/hw/xwin/glx/winpriv.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Export window information for the Windows-OpenGL GLX implementation. - * - * Authors: Alexander Gottwald - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winpriv.h" -#include "winwindow.h" - -void - 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) -{ - winTrace("%s: pWin %p XID 0x%x\n", __FUNCTION__, pWin, (unsigned int)pWin->drawable.id); - - /* a real window was requested */ - if (pWin != NULL) { - /* Get the window and screen privates */ - ScreenPtr pScreen = pWin->drawable.pScreen; - winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen); - winScreenInfoPtr pScreenInfo = NULL; - HWND hwnd = NULL; - - if (pWinScreen == NULL) { - ErrorF("winGetWindowInfo: screen has no privates\n"); - return NULL; - } - - hwnd = pWinScreen->hwndScreen; - - pScreenInfo = pWinScreen->pScreenInfo; - /* check for multiwindow mode */ - if (pScreenInfo->fMultiWindow) { - winWindowPriv(pWin); - - if (pWinPriv == NULL) { - ErrorF("winGetWindowInfo: window has no privates\n"); - return hwnd; - } - - if (pWinPriv->hWnd == NULL) { - winCreateWindowsWindow(pWin); - winDebug("winGetWindowInfo: forcing window to exist\n"); - } - - if (pWinPriv->hWnd != NULL) { - /* copy window handle */ - hwnd = pWinPriv->hWnd; - - /* mark GLX active on that hwnd */ - pWinPriv->fWglUsed = TRUE; - } - - return hwnd; - } - } - else { - ScreenPtr pScreen = g_ScreenInfo[0].pScreen; - winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen); - - if (pWinScreen == NULL) { - ErrorF("winGetWindowInfo: screen has no privates\n"); - return NULL; - } - - ErrorF("winGetWindowInfo: returning root window\n"); - - return pWinScreen->hwndScreen; - } - - return NULL; -} - -Bool -winCheckScreenAiglxIsSupported(ScreenPtr pScreen) -{ - winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen); - winScreenInfoPtr pScreenInfo = pWinScreen->pScreenInfo; - - if (pScreenInfo->fMultiWindow) - return TRUE; - - return FALSE; -} - -void -winSetScreenAiglxIsActive(ScreenPtr pScreen) -{ - winPrivScreenPtr pWinScreen = winGetScreenPriv(pScreen); - pWinScreen->fNativeGlActive = TRUE; -} diff --git a/hw/xwin/glx/winpriv.h b/hw/xwin/glx/winpriv.h deleted file mode 100644 index 6f695a971..000000000 --- a/hw/xwin/glx/winpriv.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Export window information for the Windows-OpenGL GLX implementation. - * - * Authors: Alexander Gottwald - */ - -#include <X11/Xwindows.h> -#include <windowstr.h> - -HWND winGetWindowInfo(WindowPtr pWin); -Bool winCheckScreenAiglxIsSupported(ScreenPtr pScreen); -void winSetScreenAiglxIsActive(ScreenPtr pScreen); diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man deleted file mode 100644 index 8d4af41db..000000000 --- a/hw/xwin/man/XWin.man +++ /dev/null @@ -1,421 +0,0 @@ -.TH XWIN 1 @vendorversion@ -.SH NAME -XWin \- X Server for the Cygwin environment on Microsoft Windows - - -.SH SYNOPSIS -.B XWin -[ options ] ... - - -.SH DESCRIPTION -\fIXWin\fP is an X Server for the X Window System on the Cygwin environment -running on Microsoft Windows. - - -.SH MODES -\fIXWin\fP can operate in 3 different modes: -.br -* \fISingle Window\fP: This is the default mode. Each X screen -appears as a single \fIWindows\fP window and all X windows are contained -within this window. -(In X terminology, the \fIWindows\fP window contains the root window for -the screen) -.br -* \fIMulti-Window\fP: In this mode \fIXWin\fP uses its own integrated -window manager in order to handle the top-level X windows, in such a -way that they appear as normal \fIWindows\fP windows. -.br -* \fIRootless\fP: In this mode the X server works in a window -containing the whole screen but this root window (traditionally covered with an X hatch -pattern) is hidden from view, so only top-level X windows are seen. - -.SH OPTIONS -In addition to the normal server options described in the \fIXserver(1)\fP -manual page, \fIXWin\fP accepts the following command line switches, -\fIall\fP of which are optional: - -.SH OPTIONS CONTROLLING WINDOWING MODE -Only one of these options may be specified. -.TP 8 -.B (default) -Windowed or rooted mode. -Each X screen appears as a single \fIWindows\fP window and all X windows are -contained within those windows. -.TP 8 -.B \-multiwindow -Each top-level X window appears in its own \fIWindows\fP window. -Also start the integrated \fIWindows\fP-based window manager. -.TP 8 -.B \-rootless -Run the server in rootless mode. -The X server works on a window covering the whole screen but the root window -is hidden from view. -.PP -\fBNOTE:\fP \fI-multiwindow\fP mode uses its own internal window manager. -All other modes require an external window manager in order to move, resize, and perform other -operations on the individual X windows. - -.SH OPTIONS FOR SPECIFYING X SCREENS -An X display may be composed of multiple screens. -The default behaviour is to create a single screen 0 that is roughly the -size of useful area of the primary monitor (allowing for any window -decorations and the task-bar). - -Screen specific parameters can be applied as a -default to all screens by placing those screen specific parameters -before any \fB\-screen\fP parameter. Screen specific parameters placed after -the first \fB\-screen\fP parameter will apply only to the immediately -preceding \fB\-screen\fP parameter. -.TP 8 -.B \-[no]multimonitors or \-[no]multiplemonitors -Create a screen 0 that covers all monitors [the primary monitor] on a system with -multiple monitors. -Fake XINERAMA data is created describing the individual monitors, -(This is similar to the 'merged framebuffer' or 'pseudo-xinerama' mode provided by -some drivers for the xorg X server). -This option is currently enabled by default in \fB\-multiwindow\fP mode. -.TP 8 -.B "\-screen \fIscreen_number\fP [\fIW\fP \fIH\fP [\fIX\fP \fIY\fP] | [[\fIW\fPx\fIH\fP[+\fIX\fP+\fIY\fP]][@\fIM\fP]] ] " -Create screen number -.I screen_number -and optionally specify its -.I height, -.I width -and -.I initial position. -Additionally a -.I -monitor number -(which count from 1) can be specified to place the screen on, -at which point, all coordinates become relative to that monitor. -Screen numbers must be contiguous starting from zero and cannot be duplicated. - -Examples: - -.I " -screen 0 @1 ; on 1st monitor using its full resolution (the default)" - -.I " -screen 0 800x600+100+100@2 ; on 2nd monitor offset 100,100 size 800x600" - -.I " -screen 0 1024x768@3 ; on 3rd monitor size 1024x768" - -.SH OPTIONS CONTROLLING THE APPEARANCE OF THE X SCREEN WINDOWS -These parameters only apply to windowed mode screens i.e. not -in \fB-multiwindow\fP or \fB-rootless\fP mode. -.TP 8 -.B "\-fullscreen" -The X server window takes the full screen, covering completely the -\fIWindows\fP desktop. -Currently \fB\-fullscreen\fP may only be applied to one X screen. -.TP 8 -.B "\-icon" \fIicon-specifier\fP -Override the window icon for the screen window from the default. -The \fIicon-specifier\fP is as defined in \fIXWinrc(@filemansuffix@)\fP. -.TP 8 -.B \-nodecoration -Do not give the Cygwin/X window a \fIWindows\fP window border, title bar, -etc. -This parameter is ignored when the \fB\-fullscreen\fP parameter is specified. -.TP 8 -.B \-scrollbars -Alternative name for \fB\-resize=scrollbars\fP. - -.SH OPTIONS CONTROLLING RESIZE BEHAVIOUR -.TP 8 -.B \-resize[=none|scrollbars|randr] -Select the resize mode of an X screen. -The default is \fBnone\fP if \fB\-fullscreen\fP is used, \fBrandr\fP otherwise. - -.RS -.IP \fB\-resize=none\fP 8 -The screen is not resizable. - -In windowed mode, if the window has decorations, a fixed frame is used. - -Alternative name is \fB\-noresize\fP. - -.IP \fB\-resize=scrollbars\fP 8 -The screen window is resizeable, but the screen is not resizable. - -In windowed mode, if the window has decorations, a resizing frame is used. -Scrollbars are drawn when needed to allow the entire X screen -to viewed by adjusting them. - -This also permits screens bigger than the \fIWindows\fP virtual desktop to be used. - -This parameter is ignored in \fB-multiwindow\fP or \fB-rootless\fP mode. -Alternative name is \fB\-scrollbars\fP. - -.IP \fB\-resize=randr\fP 8 -The screen is resizable and the screen window is resizeable. - -In windowed mode, if the window has decorations, a resizing frame is used. - -Resizing the \fIWindows\fP window will use the RANDR extension to change -the size of the X screen. Likewise, changing the size of -the X screen using the RANDR extension will cause the size -of the \fIWindows\fP window containing the X screen to be changed. - -In \fB-multiwindow\fP or \fB-rootless\fP mode, if the X screen is -of the same dimensions as a Windows monitor or the virtual desktop, -the X server will respond to the WM_DISPLAYCHANGED sent when those -dimensions change by resizing the X screen. Changing the size -of the X screen using the RANDR extension is not permitted. - -The maximum dimensions of the screen are the dimensions of the \fIWindows\fP virtual desktop. - -.IP \fB\-resize\fP 8 -on its own is equivalent to \fB\-resize=randr\fP -.RE - -.SH OPTIONS FOR MULTIWINDOW MODE -.TP 8 -.B \-[no]hostintitle -Add the host name to the window title for X applications which are running -on remote hosts, when that information is available and it's useful to do so. -The default is enabled. -.TP 8 -.B \-[no]compositewm -Use Composite extension redirection to maintain a bitmap image of each top-level -X window, so window contents which are occluded show correctly in task bar and -task switcher previews. -The default is enabled. -.TP 8 -.B \-[no]compositealpha -X windows with per-pixel alpha are composited into the \fIWindows\fP desktop -(i.e. a \fIWindows\fP window can be seen through any transparency in an X window -placed over it). - -This option has no effect on Windows 8 and 8.1. -This option has no effect if \fB-compositewm\fP is disabled. -The default is disabled. - -.SH OPTIONS CONTROLLING WINDOWS INTEGRATION -.TP 8 -.B \-[no]clipboard -Enables [disables] the integration between the X11 clipboard and -\fIWindows\fP clipboard. The default is enabled. -.TP 8 -.B "\-emulate3buttons [\fItimeout\fP]" -Emulate a three button mouse; pressing both buttons within -.I timeout -milliseconds causes an emulated middle button press. The default -.I timeout -is 50 milliseconds. Note that most mice with scroll wheel have middle -button functionality, usually you will need this option only if you have -a two button mouse without scroll wheel. Default is to enable this -option if \fIWindows\fP reports a two button mouse, disabled otherwise. -.TP 8 -.B \-[no]keyhook -Enable [disable] a low-level keyboard hook for catching -special keypresses like Menu and Alt+Tab and passing them to the X -Server instead of letting \fIWindows\fP handle them. -.TP 8 -.B \-lesspointer -Normally the \fIWindows\fP mouse cursor is hidden when the mouse is -over an active Cygwin/X window. This option causes the mouse cursor -also to be hidden when it is over an inactive Cygwin/X window. This -prevents the \fIWindows\fP mouse cursor from being drawn on top of the X -cursor. -This parameter has no effect unless \fB-swcursor\fP is also specified. -.TP 8 -.B \-[no]primary -Clipboard integration may [will not] use the PRIMARY selection. -The default is enabled. -.TP 8 -.B \-swcursor -Disable the usage of the \fIWindows\fP cursor and use the X11 software cursor instead. -This option is ignored if \fB-compositewm\fP is also enabled. -.TP 8 -.B \-[no]trayicon -Do not create a tray icon. Default is to create one -icon per screen. You can globally disable tray icons with -\fB\-notrayicon\fP, then enable it for specific screens with -\fB\-trayicon\fP for those screens. -.TP 8 -.B \-[no]unixkill -Enable or disable the \fICtrl-Alt-Backspace\fP key combination as a -signal to exit the X Server. The \fICtrl-Alt-Backspace\fP key combination -is disabled by default. -.TP 8 -.B \-[no]wgl -Enable [disable] the GLX extension to use the native Windows WGL interface -for hardware accelerated OpenGL (AIGLX). The default is enabled. -.TP 8 -.B \-[no]winkill -Enable or disable the \fIAlt-F4\fP key combination as a signal to exit the -X Server. -The \fIAlt-F4\fP key combination is enabled by default. - -.SH DRAWING ENGINE OPTIONS -.TP 8 -.B "\-clipupdates \fInum_boxes\fP" -Specify an optional threshold, above which the regions in a shadow -update operation will be collected into a GDI clipping region. The -clipping region is then used to do a single bit block transfer that is -constrained to the updated area by the clipping region. There is some -overhead involved in creating, installing, destroying, and removing -the clipping region, thus there may not be much benefit for a small -number of boxes (less than 10). It is even possible that this -functionality does not provide a benefit at any number of boxes; we -can only determine the usefulness of this feature through testing. -This option probably has limited effect on current \fIWindows\fP versions -as they already perform GDI batching. -.TP 8 -.B "\-engine \fIengine_type_id\fP" -This option, which is intended for Cygwin/X developers, -overrides the server's automatically selected drawing engine type. This -parameter will be ignored if the specified drawing engine type is not -supported on the current system. - -Default behavior is to select the drawing engine with optimum performance that -supports the specified depth and window configuration. - -The engine type ids are: -.RS -.IP 1 4 -Shadow GDI -.IP 4 4 -Shadow DirectDraw Non-Locking -.RE - -.SH FULLSCREEN OPTIONS -.TP 8 -.B "\-depth \fIdepth\fP" -Specify the color depth, in bits per pixel, to use when running in -fullscreen with a DirectDraw engine. This parameter is ignored if -\fB\-fullscreen\fP is not specified. -.TP 8 -.B "\-refresh \fIrate_in_Hz\fP" -Specify an optional refresh rate to use when running in -fullscreen with a DirectDraw engine. This parameter is ignored if -\fB\-fullscreen\fP is not specified. - -.SH MISCELLANEOUS OPTIONS -See also the normal server options described in the \fIXserver(1)\fP -manual page - -.TP 8 -.B \-help -Write a help text listing supported command line options and their description to the console. -.TP 8 -.B \-ignoreinput -Ignore keyboard and mouse input. This is usually only used for testing -and debugging purposes. -.TP 8 -.B "\-logfile \fIfilename\fP" -Change the server log file from the default of \fI -@logdir@/XWin.n.log\fP, -where \fIn\fP is the display number of the XWin server, to \fIfilename\fP. -.TP 8 -.B "\-logverbose \fIlevel\fP" -Control the degree of verbosity of the log messages with the integer -parameter \fIlevel\fP. For \fIlevel\fP=0 only fatal errors are -reported, for \fIlevel\fP=1 simple information about -configuration is also given, for \fIlevel\fP=2 (default) -additional runtime information is recorded -and for \fIlevel\fP=3 detailed log -information (including trace and debug output) is produced. Bigger -values will yield a still more detailed debug output. -.TP 8 -.B "\-xkblayout \fIlayout\fP" -.TP 8 -.B "\-xkbmodel \fImodel\fP" -.TP 8 -.B "\-xkboptions \fIoption\fP" -.TP 8 -.B "\-xkbrules \fIrule\fP" -.TP 8 -.B "\-xkbvariant \fIvariant\fp" -These options configure the xkeyboard extension to load -a particular keyboard map as the X server starts. The behavior is similar -to the \fIsetxkbmap\fP(1) program. - -See the \fIxkeyboard-config\fP(@miscmansuffix@) manual page for a list of -keyboard configurations. - -The keyboard layout data is located at \fI@datadir@/X11/xkb/\fP. Additional information -can be found in the README files there and in the \fIsetxkbmap\fP(1) manual page. - -For example, in order to load a German layout for a pc105 keyboard, use the options: -.br -.I " \-xkblayout de \-xkbmodel pc105" - -Alternatively, you can use the \fIsetxkbmap\fP(1) program after \fIXWin\fP is -running. - -The default is to select a keyboard configuration matching your current layout as -reported by \fIWindows\fP, if known, or the default X server configuration -if no matching keyboard configuration was found. - -.SH UNDOCUMENTED OPTIONS -These options are undocumented. Do not use them. - -.TP 8 -.B \-emulatepseudo -Create a depth 8 PseudoColor visual when running in depths 15, 16, 24, -or 32, collectively known as TrueColor depths. -Color map manipulation is not supported, so the PseudoColor visual will -not have the correct colors. -This option is intended to allow applications which only work with a depth 8 -visual to operate in TrueColor modes. - -.SH LOG FILE -As it runs \fIXWin\fP writes messages indicating the most relevant events -to the console -from which it was called and to a log file that by default is located at \fI -@logdir@/XWin.0.log\fP. This file is mainly for debugging purposes. - - -.SH PREFERENCES FILE -On startup \fIXWin\fP looks for the file \fI$HOME/.XWinrc\fP or, if -the previous file does not exist, \fI -@sysconfdir@/X11/system.XWinrc\fP. \fI.XWinrc\fP allows setting -preferences for the following: -.br -* To include items into the menu associated with the \fIXWin\fP icon -which is in the \fIWindows\fP system tray. This functions in all -modes that have a tray icon. -.br -* To include items in the system menu which is associated with the \fIWindows\fP -window that \fIXWin -multiwindow\fP produces for each top-level X -window, in both the generic case and for particular programs. -.br -* To change the icon that is associated to the \fIWindows\fP window that -\fIXWin -multiwindow\fP produces for each top-level X-window. -.br -* To change the style that is associated to the \fIWindows\fP window that -\fXWin I-multiwindow\fP produces for each top-level X window. -.PP -The format of the \fI.XWinrc\fP file is given in the XWinrc(5) manual page. - -.SH EXAMPLES -Need some examples - - -.SH "SEE ALSO" -X(@miscmansuffix@), Xserver(1), xdm(1), xinit(1), XWinrc(@filemansuffix@), -setxkbmap(1), xkeyboard-config(@miscmansuffix@). - - -.SH BUGS -.I XWin -and this manual page still have many limitations. - -The \fIXWin\fP software is continuously developing; it is therefore possible that -this manual page is not up to date. It is always prudent to -look also at the output of \fIXWin -help\fP in order to -check the options that are operative. - - -.SH AUTHORS -This list is by no means complete, but direct contributors to the -Cygwin/X project include (in alphabetical order by last name): Stuart -Adamson, Michael Bax, Jehan Bing, Lev Bishop, Dr. Peter Busch, Biju G -C, Robert Collins, Nick Crabtree, Early Ehlinger, Christopher Faylor, -John Fortin, Brian Genisio, Fabrizio Gennari, Alexander Gottwald, Ralf -Habacker, Colin Harrison, Matthieu Herrb, Alan Hourihane, Pierre A -Humblet, Harold L Hunt II, Dakshinamurthy Karra, Joe Krahn, -Paul Loewenstein, Kensuke Matsuzaki, -Takuma Murakami, Earle F. Philhower III, Benjamin Riefenstahl, Yaakov Selkowitz, -Suhaib Siddiqi, Jack Tanner, Jon Turney and Nicholas Wourms. diff --git a/hw/xwin/man/XWinrc.man b/hw/xwin/man/XWinrc.man deleted file mode 100644 index 3c1ed067d..000000000 --- a/hw/xwin/man/XWinrc.man +++ /dev/null @@ -1,256 +0,0 @@ -.TH XWIN @filemansuffix@ @vendorversion@ - - -.SH NAME -XWinrc\- XWin Server Resource Configuration File. - - -.SH DESCRIPTION -The X Server for the X Window System on the Cygwin/X environment -running on Microsoft Windows, \fIXWin\fP can be optionally configured -with the \fIXWinrc\fP file. A system-wide configuration file should -be placed in \fI -@sysconfdir@/X11/system.XWinrc\fP, a per-user file -should be put at \fI$HOME/.XWinrc\fP. The \fIsystem.XWinrc\fP file is -read only if no \fI$HOME/.XWinrc\fP exist. -.PP -With the \fI.XWinrc\fP configuration file it is possible to do the -following: -.PP -1- To include items into the menu associated with the \fIXWin\fP icon -which is in the \fIWindows\fP system tray. This feature functions in -all XWin modes that have such tray icon. -.PP -2- To include items into the menu which is associated with the -\fIWindows\fP window that \fIXWin -multiwindow\fP produces for each -top-level X-window. That can be done both for the generic case and -for particular programs. -.PP -3- To change the icon that is associated to the \fIWindows\fP window -that \fIXWin -multiwindow\fP produces for each top-level X-window. -Again, that can be done both for the generic case and for particular -programs. The new icons associated should be \fIWindows\fP format -icons \fI.ico\fP. -.PP -4- To change the style that is associated to the \fIWindows\fP window -that \fI-multiwindow\fP produces for each top-level X window. Again, -that can be done both for the generic case and for particular programs. - - -.SH FILE FORMAT -.B Keywords -are case insensitive, but in this document they will be written -completely capitalized. -.PP -.B Comments -are legal pretty much anywhere you can have an end-of-line; they -begin with "#" or "//" and go to the end-of-line. -.PP -Quote marks in strings are optional unless the string has included spaces, -or could be parsed, ambiguously, as a misplaced keyword. -.PP -There are four kinds of instructions: miscellaneous, menu, icon and style. - - -.SH Miscellaneous instruction -.TP 8 -.B DEBUG \fIString\fP -The \fIString\fP is printed to the XWin log file. - -.TP 8 -.B TRAYICON \fIicon-specifier\fB -The \fBTRAYICON\fP keyword changes the icon \fIXWin\fP displays in the -system tray area. - -.TP 8 -.B SILENTEXIT -The \fBSILENTEXIT\fP keyword, which takes no parameters, disables the -exit confirmation dialog if no clients are connected. - -.TP 8 -.B FORCEEXIT -The \fBFORCEEXIT\fP keyword, which takes no parameters, disables the -exit confirmation dialog always. Unsaved client work may be lost but -this may be useful if you want no dialogs. - -.SH Menu instructions -.TP 8 -.B MENU \fIMenu_Name\fP { -.br -.B \fIMenu_Item_Line\fP -.br -.B \fIMenu_Item_Line\fP -.br -.B \fI...\fP -.br -.B } -.br -This instruction defines a menu and asigns a \fIMenu_Name\fP to it. -\fIMenu_Item_Line\fP are lines of any of the following types: -.TP 8 -.B SEPARATOR -.TP 8 -.B \fIItem_Label\fP EXEC \fICommand\fP -.TP 8 -.B \fIItem_Label\fP MENU \fIpreviously-defined-menu-name\fP -.TP 8 -.B \fIItem_Label\fP ALWAYSONTOP -.TP 8 -.B \fIItem_Label\fP RELOAD -.br -The \fIItem_Label\fP is the string that is written in the menu item. -.br -\fICommand\fP is a string with the command that will be executed by /bin/sh. -Here paths should be \fICYGWIN\fP style (e.g. /usr/local/bin/myprogram). -A string "%display%" appearing in the \fICommand\fP will be replaced -with the proper display variable (i.e. 127.0.0.1:<display>.0). -.br -\fBALWAYSONTOP\fP sets the window to which the menu is associated to -display above all others. -.br -\fBRELOAD\fP causes the XWinrc file to be reloaded and icons and menus -regenerated. -.TP 8 -.B ROOTMENU \fIpreviously-defined-menu-name\fP -Includes the items in the indicated menu into the menu associated with -\fIXWin\fP that appears in the system tray. -.TP 8 -.B DEFAULTSYSMENU \fIpreviously-defined-menu-name\fP ATSTART|ATEND -Includes the items in the indicated menu into the menu associated with -generic top-level X-Windows in the \fIXWin\fP \fImultiwindow\fP mode. The -keywords \fBATSTART\fP and \fBATEND\fP indicate if such items should be -included at the start or at the end of the menu. -.TP 8 -.B SYSMENU { - \fIclass-or-name-of-window\fP \fIdefined-menu-name\fP \fBATSTART|ATEND\fP -.br - \fI...\fP -.br - \fB}\fP -.br -Associates a specific menu to a specified window class or name -in \fI-multiwindow\fP mode. The keywords ATSTART or ATEND indicate if -such items should be included at the start or at the end of the menu. - - -.SH Icon Instructions -When specifying an \fIicon-specifier\fP in the following commands several different formats are allowed: -.PP -.IP \fI"NAME.ICO"\fP 16 -filename of an .ico format file -.br -(e.g. "cygwin.ico", "apple.ico", "C:\\icons\\cheese.ico", "/usr/share/icons/moon.ico") -.IP \fI"NAME.DLL,nnn"\fP 16 -filename of a DLL with an index into its ICON resources -.br -(e.g. "c:\\windows\\system32\\shell32.dll,4", the default folder icon, - "/usr/bin/cygicons-0.dll,10", the hippo icon) -.IP \fI",nnn"\fP 16 -index into the XWin executable's internal ICON resources -.br -(e.g. ",101" is the 1st icon in \fIXWin\fP) -.TP 8 -.B ICONDIRECTORY \fIWindows-path-to-icon-directory\fP -Defines the default directory for the file when an \fIicon-specifier\fP doesn't -contain an absolute path. -It should be a \fIWindows\fP style path (e.g. C:\\cygwin\\usr\\local\\icons). -.TP 8 -.B DEFAULTICON \fIicon-specifier\fP -Defines a replacement for the standard X icon for applications without -specified icons. -.TP 8 -.B ICONS { -.br - \fIclass-or-name-of-window\fP \fIicon-specifier\fP -.br - \fI...\fP -.br - \fB}\fP -.br -Defines icon replacements windows matching the specified window class or names. -If multiple name or class matches occur for a window, only the first one -will be used. - -.SH Style Instructions -.TP 8 -.B STYLES { -\fIclass-or-name-of-window\fP \fIstyle-keyword-1\fP \fIstyle-keyword-2\fP -.br - \fI...\fP -.br -\fB}\fP - -Associates specific styles to a specified window class or name -in \fI-multiwindow\fP mode. If multiple class or name matches occur, -for a window, only the first one will be used. - -The style keywords indicate the following: - -\fIstyle-keyword-1\fP - -\fBTOPMOST\fP -.br -Open the class or name above all NOTOPMOST Microsoft Windows -.br -\fBMAXIMIZE\fP -.br -Start the class or name fullscreen. -.br -\fBMINIMIZE\fP -.br -Start the class or name iconic. -.br -\fBBOTTOM\fP -.br -Open the class or name below all Windows windows. -.br - -\fIstyle-keyword-2\fP - -\fBNOTITLE\fP -.br -No Windows title bar, for the class or name. -.br -\fBOUTLINE\fP -.br -No Windows title bar and just a thin-line border, for the class or name. -.br -\fBNOFRAME\fP -.br -No Windows title bar or border, for the class or name. - -One keyword in \fIstyle-keyword-1\fP can be used with one keyword in \fIstyle-keyword-2\fP, -or any keyword can be used singly. - - -.SH EXAMPLE -.TP 8 -This example adds an Xterm menu item to the system tray icon -\fBMENU systray { -.br -\t xterm EXEC "xterm -display %display% -sb -sl 999" -.br -\t SEPARATOR -.br -} -.br -ROOTMENU systray -\fP - -.TP 8 -This example makes an oclock window frameless in \fI-multiwindow\fP mode -\fBSTYLES { -.br -\t oclock NOFRAME -.br -} - - - -.SH "SEE ALSO" - XWin(1) - - -.SH AUTHOR -The XWinrc feature of XWin was written primarily by Earle F. Philhower -III. Extended for style configuration by Colin Harrison. diff --git a/hw/xwin/meson.build b/hw/xwin/meson.build deleted file mode 100644 index 546777c64..000000000 --- a/hw/xwin/meson.build +++ /dev/null @@ -1,188 +0,0 @@ -windows = import('windows') - -windowsdri_dep = dependency('windowsdriproto', required: false) - -build_windowsdri = windowsdri_dep.found() - -xwin_sys_libs = [] -xwin_sys_libs += '-ldxguid' - -if host_machine.system() == 'cygwin' - server_name = 'XWin' -else - server_name = 'Xming' - xwin_sys_libs += ['-lpthread', '-lws2_32'] -endif - -xwin_c_args = [] -xwin_c_args += '-DHAVE_XWIN_CONFIG_H' -xwin_c_args += '-Wno-bad-function-cast' - -srcs_windows = [ - 'winclipboardinit.c', - 'winclipboardwrappers.c', -] -subdir('winclipboard') - -xwin_glx = [] -xwin_windowsdri = [] -if build_glx - if build_windowsdri - xwin_c_args += '-DXWIN_WINDOWS_DRI' - subdir('dri') - endif - xwin_c_args += '-DXWIN_GLX_WINDOWS' - xwin_sys_libs += '-lopengl32' - subdir('glx') -endif - -srcs_windows += [ - 'winmultiwindowshape.c', - 'winmultiwindowwindow.c', - 'winmultiwindowwm.c', - 'winmultiwindowwndproc.c', - 'propertystore.h', - 'winSetAppUserModelID.c', -] -xwin_sys_libs += ['-lshlwapi', '-lole32', '-ldwmapi'] - -srcs_windows += [ - 'winrandr.c', -] - -srcs_windows += [ - 'InitInput.c', - 'InitOutput.c', - 'winallpriv.c', - 'winauth.c', - 'winblock.c', - 'wincmap.c', - 'winconfig.c', - 'wincreatewnd.c', - 'wincursor.c', - 'windialogs.c', - 'winengine.c', - 'winerror.c', - 'winglobals.c', - 'winkeybd.c', - 'winkeyhook.c', - 'winmisc.c', - 'winmonitors.c', - 'winmouse.c', - 'winmsg.c', - 'winmsgwindow.c', - 'winmultiwindowclass.c', - 'winmultiwindowicons.c', - 'winos.c', - 'winprefs.c', - 'winprocarg.c', - 'winscrinit.c', - 'winshadddnl.c', - 'winshadgdi.c', - 'wintaskbar.c', - 'wintrayicon.c', - 'winvalargs.c', - 'winwakeup.c', - 'winwindow.c', - 'winwndproc.c', - 'ddraw.h', - 'winconfig.h', - 'win.h', - 'winglobals.h', - 'winkeybd.h', - 'winkeynames.h', - 'winlayouts.h', - 'winmessages.h', - 'winmonitors.h', - 'winmsg.h', - 'winms.h', - 'winmultiwindowclass.h', - 'winmultiwindowicons.h', - 'winprefs.h', - 'winresource.h', - 'winwindow.h', - 'windisplay.c', - 'windisplay.h', - '../../mi/miinitext.c', - '../../mi/miinitext.h', -] - -rsrc = windows.compile_resources( - 'XWin.rc', - include_directories: include_directories('../../include/'), - depend_files: ['XWin.exe.manifest', 'X.ico'], -) -srcs_windows += rsrc - -flex = find_program('flex') -bison = find_program('bison') - -lgen = generator( - flex, - output : '@PLAINNAME@.yy.c', - arguments : ['-i', '-o', '@OUTPUT@', '@INPUT@'] -) - -lfiles = lgen.process('winprefslex.l') -srcs_windows += lfiles - -pgen = generator( - bison, - output : ['@BASENAME@.c', '@BASENAME@.h'], - arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@'] -) - -pfiles = pgen.process('winprefsyacc.y') -srcs_windows += pfiles - -xwin_dep = [ - common_dep, - dependency('xcb-aux'), - dependency('xcb-image'), - dependency('xcb-ewmh'), - dependency('xcb-icccm'), - dependency('xcb-composite'), -] - -executable( - server_name, - srcs_windows, - include_directories: [inc, top_dir_inc], - dependencies: xwin_dep, - link_with: [ - xwin_windowsdri, - xwin_glx, - xwin_clipboard, - libxserver_fb, - libxserver, - libxserver_glx, - libglxvnd, - libxserver_xkb_stubs, - libxserver_miext_shadow, - libxserver_pseudoramix, - libxserver_xi_stubs, - ], - link_args: ['-Wl,--disable-stdcall-fixup', '-Wl,--export-all-symbols'] + xwin_sys_libs, - c_args: xwin_c_args, - gui_app: true, - install: true, -) - -install_data( - 'system.XWinrc', - install_dir: join_paths(get_option('sysconfdir'), 'X11') -) - -xwin_man = configure_file( - input: 'man/XWin.man', - output: 'XWin.1', - configuration: manpage_config, -) -install_man(xwin_man) - -xwinrc_man = configure_file( - input: 'man/XWinrc.man', - output: 'XWinrc.5', - configuration: manpage_config, -) -install_man(xwinrc_man) diff --git a/hw/xwin/propertystore.h b/hw/xwin/propertystore.h deleted file mode 100644 index 6afc6c954..000000000 --- a/hw/xwin/propertystore.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2011 Tobias Häußler - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef PROPERTYSTORE_H -#define PROPERTYSTORE_H - -#include <windows.h> - -#ifdef __MINGW64_VERSION_MAJOR -/* If we are using headers from mingw-w64 project, it provides the PSDK headers this needs ... */ -#include <propkey.h> -#include <propsys.h> -#else /* !__MINGW64_VERSION_MAJOR */ -/* ... otherwise, we need to define all this stuff ourselves */ - -typedef struct _tagpropertykey { - GUID fmtid; - DWORD pid; -} PROPERTYKEY; - -#define REFPROPERTYKEY const PROPERTYKEY * -#define REFPROPVARIANT const PROPVARIANT * - -WINOLEAPI PropVariantClear(PROPVARIANT *pvar); - -#ifdef INTERFACE -#undef INTERFACE -#endif - -#define INTERFACE IPropertyStore -DECLARE_INTERFACE_(IPropertyStore, IUnknown) -{ - STDMETHOD(QueryInterface) (THIS_ REFIID, PVOID *) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - STDMETHOD(GetCount) (THIS_ DWORD) PURE; - STDMETHOD(GetAt) (THIS_ DWORD, PROPERTYKEY) PURE; - STDMETHOD(GetValue) (THIS_ REFPROPERTYKEY, PROPVARIANT) PURE; - STDMETHOD(SetValue) (THIS_ REFPROPERTYKEY, REFPROPVARIANT) PURE; - STDMETHOD(Commit) (THIS) PURE; -}; - -#undef INTERFACE -typedef IPropertyStore *LPPROPERTYSTORE; - -DEFINE_GUID(IID_IPropertyStore, 0x886d8eeb, 0x8cf2, 0x4446, 0x8d, 0x02, 0xcd, - 0xba, 0x1d, 0xbd, 0xcf, 0x99); - -#ifdef INITGUID -#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } -#else -#define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) GUID_EXT const PROPERTYKEY name -#endif - -DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, - 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5); - -#endif /* !__MINGW64_VERSION_MAJOR */ - -typedef HRESULT(__stdcall * SHGETPROPERTYSTOREFORWINDOWPROC) (HWND, REFIID, - void **); - -#endif diff --git a/hw/xwin/system.XWinrc b/hw/xwin/system.XWinrc deleted file mode 100644 index fb44be37d..000000000 --- a/hw/xwin/system.XWinrc +++ /dev/null @@ -1,124 +0,0 @@ -# XWin Server Resource File - EXAMPLE -# Earle F. Philhower, III - -# Place in ~/.XWinrc or in /etc/X11/system.XWinrc - -# Keywords are case insensitive, comments legal pretty much anywhere -# you can have an end-of-line - -# Comments begin with "#" or "//" and go to the end-of-line - -# Menus are defined as... -# MENU <name> { -# <Menu Text> EXEC <command> -# ^^ This command will have any "%display%" -# string replaced with the proper display -# variable (i.e. 127.0.0.1:<display>.0) -# (This should only rarely be needed as -# the DISPLAY environment variable is also -# set correctly) -# or <Menu Text> MENU <name-of-some-prior-defined-menu> -# or <Menu Text> ALWAYSONTOP -# ^^ Sets the window to display above all others -# or <Menu Text> RELOAD -# ^^ Causes ~/.XWinrc or the system.XWinrc file -# to be reloaded and icons and menus regenerated -# or SEPARATOR -# ... -# } - -# Set the taskmar menu with -# ROOTMENU <name-of-some-prior-defined-menu> - -# If you want a menu to be applied to all popup window's system menu -# DEFAULTSYSMENU <name-of-some-prior-defined-menu> <atstart|atend> - -# To choose a specific menu for a specific WM_CLASS or WM_NAME use ... -# SYSMENU { -# <class-or-name-of-window> <name-of-prior-defined-menu> <atstart|atend> -# ... -# } - -# When specifying an ICONFILE in the following commands several different -# formats are allowed: -# 1. Name of a regular Windows .ico format file -# (ex: "cygwin.ico", "apple.ico") -# 2. Name and index into a Windows .DLL -# (ex: "c:\windows\system32\shell32.dll,4" gives the default folder icon -# "c:\windows\system32\shell32.dll,5" gives the floppy drive icon) -# 3. Index into XWin.EXE internal ICON resource -# (ex: ",101" is the 1st icon inside XWin.exe) - -# To define where ICO files live (** Windows path**) -# ICONDIRECTORY <windows-path i.e. c:\cygwin\usr\icons> -# NOTE: If you specify an absolute path in Windows or Cygwin format to an ICON below -# (i.e. "c:\icons\xxx.ico" or "/usr/share/icons/xxx.ico") -# this ICONDIRECTORY will not be prepended - -# To change the taskbar icon use... -# TRAYICON <icon-specifier> - -# To define a replacement for the standard X icon for apps w/o specified icons -# DEFAULTICON <icon-specifier> - -# To define substitute icons on a per-window basis use... -# ICONS { -# <class-or-name-of-window> <icon-file-name.ico> -# ... -# } -# In the case where multiple matches occur, the first listed in the ICONS -# section will be chosen. - -# To disable exit confirmation dialog add the line containing SilentExit - -# DEBUG <string> prints out the string to the XWin.log file - -// Below are just some silly menus to demonstrate writing your -// own configuration file. - -// Make some menus... -menu apps { - xterm exec "xterm" - "Emacs" exec "emacs" - notepad exec notepad - xload exec "xload -display %display%" # Comment -} - -menu root { -// Comments fit here, too... - "Reload .XWinrc" RELOAD - "Applications" menu apps - SEParATOR -} - -menu aot { - Separator - "Always on Top" alwaysontop -} - -menu xtermspecial { - "Emacs" exec "emacs" - "Always on Top" alwaysontop - SepArAtor -} - -RootMenu root - -DefaultSysMenu aot atend - -SysMenu { - "xterm" xtermspecial atstart -} - -# IconDirectory "c:\winnt\" - -# DefaultIcon "reinstall.ico" - -# Icons { -# "xterm" "uninstall.ico" -# } - -SilentExit - -DEBUG "Done parsing the configuration file..." - diff --git a/hw/xwin/win.h b/hw/xwin/win.h deleted file mode 100644 index 48795a8b5..000000000 --- a/hw/xwin/win.h +++ /dev/null @@ -1,1045 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - * Kensuke Matsuzaki - */ - -#ifndef _WIN_H_ -#define _WIN_H_ - -#ifndef NO -#define NO 0 -#endif -#ifndef YES -#define YES 1 -#endif - -/* We can handle WM_MOUSEHWHEEL even though _WIN32_WINNT < 0x0600 */ -#ifndef WM_MOUSEHWHEEL -#define WM_MOUSEHWHEEL 0x020E -#endif - -/* Turn debug messages on or off */ -#ifndef CYGDEBUG -#define CYGDEBUG NO -#endif - -#define WIN_DEFAULT_BPP 0 -#define WIN_DEFAULT_WHITEPIXEL 255 -#define WIN_DEFAULT_BLACKPIXEL 0 -#define WIN_DEFAULT_LINEBIAS 0 -#define WIN_DEFAULT_E3B_TIME 50 /* milliseconds */ -#define WIN_DEFAULT_DPI 96 -#define WIN_DEFAULT_REFRESH 0 -#define WIN_DEFAULT_WIN_KILL TRUE -#define WIN_DEFAULT_UNIX_KILL FALSE -#define WIN_DEFAULT_CLIP_UPDATES_NBOXES 0 -#ifdef XWIN_EMULATEPSEUDO -#define WIN_DEFAULT_EMULATE_PSEUDO FALSE -#endif -#define WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH FALSE - -/* - * Windows only supports 256 color palettes - */ -#define WIN_NUM_PALETTE_ENTRIES 256 - -/* - * Number of times to call Restore in an attempt to restore the primary surface - */ -#define WIN_REGAIN_SURFACE_RETRIES 1 - -/* - * Build a supported display depths mask by shifting one to the left - * by the number of bits in the supported depth. - */ -#define WIN_SUPPORTED_BPPS ( (1 << (32 - 1)) | (1 << (24 - 1)) \ - | (1 << (16 - 1)) | (1 << (15 - 1)) \ - | (1 << ( 8 - 1))) -#define WIN_CHECK_DEPTH YES - -/* - * Timer IDs for WM_TIMER - */ -#define WIN_E3B_TIMER_ID 1 -#define WIN_POLLING_MOUSE_TIMER_ID 2 - -#define MOUSE_POLLING_INTERVAL 50 - -#define WIN_E3B_OFF -1 -#define WIN_E3B_DEFAULT 0 - -#define WIN_FD_INVALID -1 - -#define WIN_SERVER_NONE 0x0L /* 0 */ -#define WIN_SERVER_SHADOW_GDI 0x1L /* 1 */ -#define WIN_SERVER_SHADOW_DDNL 0x4L /* 4 */ - -#define AltMapIndex Mod1MapIndex -#define NumLockMapIndex Mod2MapIndex -#define AltLangMapIndex Mod3MapIndex -#define KanaMapIndex Mod4MapIndex -#define ScrollLockMapIndex Mod5MapIndex - -#define WIN_MOD_LALT 0x00000001 -#define WIN_MOD_RALT 0x00000002 -#define WIN_MOD_LCONTROL 0x00000004 -#define WIN_MOD_RCONTROL 0x00000008 - -#define WIN_24BPP_MASK_RED 0x00FF0000 -#define WIN_24BPP_MASK_GREEN 0x0000FF00 -#define WIN_24BPP_MASK_BLUE 0x000000FF - -#define WIN_MAX_KEYS_PER_KEY 4 - -#define NONAMELESSUNION - -#include <sys/types.h> -#include <sys/stat.h> -#include <stdio.h> - -#include <errno.h> -#define HANDLE void * -#include <pthread.h> -#undef HANDLE - -#ifdef HAVE_MMAP -#include <sys/mman.h> -#ifndef MAP_FILE -#define MAP_FILE 0 -#endif /* MAP_FILE */ -#endif /* HAVE_MMAP */ - -#include <X11/X.h> -#include <X11/Xproto.h> -#include <X11/Xos.h> -#include <X11/Xprotostr.h> -#include "scrnintstr.h" -#include "pixmapstr.h" -#include "pixmap.h" -#include "region.h" -#include "gcstruct.h" -#include "colormap.h" -#include "colormapst.h" -#include "miscstruct.h" -#include "servermd.h" -#include "windowstr.h" -#include "mi.h" -#include "micmap.h" -#include "mifillarc.h" -#include "mifpoly.h" -#include "input.h" -#include "mipointer.h" -#include "X11/keysym.h" -#include "micoord.h" -#include "miline.h" -#include "shadow.h" -#include "fb.h" - -#include "mipict.h" -#include "picturestr.h" - -#ifdef RANDR -#include "randrstr.h" -#endif - -/* - * Windows headers - */ -#include "winms.h" -#include "winresource.h" - -/* - * Define Windows constants - */ - -#define WM_TRAYICON (WM_USER + 1000) -#define WM_INIT_SYS_MENU (WM_USER + 1001) -#define WM_GIVEUP (WM_USER + 1002) - -/* Local includes */ -#include "winwindow.h" -#include "winmsg.h" - -/* - * Debugging macros - */ - -#if CYGDEBUG -#define DEBUG_MSG(str,...) \ -if (fDebugProcMsg) \ -{ \ - char *pszTemp; \ - int iLength; \ - if (asprintf (&pszTemp, str, ##__VA_ARGS__) != -1) { \ - MessageBox (NULL, pszTemp, szFunctionName, MB_OK); \ - free (pszTemp); \ - } \ -} -#else -#define DEBUG_MSG(str,...) -#endif - -#if CYGDEBUG -#define DEBUG_FN_NAME(str) PTSTR szFunctionName = str -#else -#define DEBUG_FN_NAME(str) -#endif - -#if CYGDEBUG || YES -#define DEBUGVARS BOOL fDebugProcMsg = FALSE -#else -#define DEBUGVARS -#endif - -#if CYGDEBUG || YES -#define DEBUGPROC_MSG fDebugProcMsg = TRUE -#else -#define DEBUGPROC_MSG -#endif - -#define PROFILEPOINT(point,thresh)\ -{\ -static unsigned int PROFPT##point = 0;\ -if (++PROFPT##point % thresh == 0)\ -ErrorF (#point ": PROFILEPOINT hit %u times\n", PROFPT##point);\ -} - -#define DEFINE_ATOM_HELPER(func,atom_name) \ -static Atom func (void) { \ - static int generation; \ - static Atom atom; \ - if (generation != serverGeneration) { \ - generation = serverGeneration; \ - atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \ - } \ - return atom; \ -} - -/* - * Typedefs for engine dependent function pointers - */ - -typedef Bool (*winAllocateFBProcPtr) (ScreenPtr); - -typedef void (*winFreeFBProcPtr) (ScreenPtr); - -typedef void (*winShadowUpdateProcPtr) (ScreenPtr, shadowBufPtr); - -typedef Bool (*winInitScreenProcPtr) (ScreenPtr); - -typedef Bool (*winCloseScreenProcPtr) (ScreenPtr); - -typedef Bool (*winInitVisualsProcPtr) (ScreenPtr); - -typedef Bool (*winAdjustVideoModeProcPtr) (ScreenPtr); - -typedef Bool (*winCreateBoundingWindowProcPtr) (ScreenPtr); - -typedef Bool (*winFinishScreenInitProcPtr) (int, ScreenPtr, int, char **); - -typedef Bool (*winBltExposedRegionsProcPtr) (ScreenPtr); - -typedef Bool (*winBltExposedWindowRegionProcPtr) (ScreenPtr, WindowPtr); - -typedef Bool (*winActivateAppProcPtr) (ScreenPtr); - -typedef Bool (*winRedrawScreenProcPtr) (ScreenPtr pScreen); - -typedef Bool (*winRealizeInstalledPaletteProcPtr) (ScreenPtr pScreen); - -typedef Bool (*winInstallColormapProcPtr) (ColormapPtr pColormap); - -typedef Bool (*winStoreColorsProcPtr) (ColormapPtr pmap, - int ndef, xColorItem * pdefs); - -typedef Bool (*winCreateColormapProcPtr) (ColormapPtr pColormap); - -typedef Bool (*winDestroyColormapProcPtr) (ColormapPtr pColormap); - -typedef Bool (*winCreatePrimarySurfaceProcPtr) (ScreenPtr); - -typedef Bool (*winReleasePrimarySurfaceProcPtr) (ScreenPtr); - -typedef Bool (*winCreateScreenResourcesProc) (ScreenPtr); - -/* - * Pixmap privates - */ - -typedef struct { - HBITMAP hBitmap; - void *pbBits; - BITMAPINFOHEADER *pbmih; - BOOL owned; -} winPrivPixmapRec, *winPrivPixmapPtr; - -/* - * Colormap privates - */ - -typedef struct { - HPALETTE hPalette; - LPDIRECTDRAWPALETTE lpDDPalette; - RGBQUAD rgbColors[WIN_NUM_PALETTE_ENTRIES]; - PALETTEENTRY peColors[WIN_NUM_PALETTE_ENTRIES]; -} winPrivCmapRec, *winPrivCmapPtr; - - -/* - * Windows Cursor handling. - */ - -typedef struct { - /* from GetSystemMetrics */ - int sm_cx; - int sm_cy; - - BOOL visible; - HCURSOR handle; - QueryBestSizeProcPtr QueryBestSize; - miPointerSpriteFuncPtr spriteFuncs; -} winCursorRec; - -/* - * Resize modes - */ -typedef enum { - resizeDefault = -1, - resizeNotAllowed, - resizeWithScrollbars, - resizeWithRandr -} winResizeMode; - -/* - * Screen information structure that we need before privates are available - * in the server startup sequence. - */ - -typedef struct { - ScreenPtr pScreen; - - /* Did the user specify a height and width? */ - Bool fUserGaveHeightAndWidth; - - DWORD dwScreen; - - int iMonitor; - 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; -#ifdef XWIN_EMULATEPSEUDO - Bool fEmulatePseudo; -#endif - Bool fFullScreen; - Bool fDecoration; - Bool fRootless; - Bool fMultiWindow; - Bool fCompositeWM; - Bool fMultiMonitorOverride; - 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; - - /* Icons for screen window */ - HICON hIcon; - HICON hIconSm; -} winScreenInfo, *winScreenInfoPtr; - -/* - * Screen privates - */ - -typedef struct _winPrivScreenRec { - winScreenInfoPtr pScreenInfo; - - Bool fEnabled; - Bool fClosed; - Bool fActive; - Bool fBadDepth; - - int iDeltaZ; - int iDeltaV; - - int iConnectedClients; - - CloseScreenProcPtr CloseScreen; - - DWORD dwRedMask; - DWORD dwGreenMask; - DWORD dwBlueMask; - DWORD dwBitsPerRGB; - - DWORD dwModeKeyStates; - - /* Handle to icons that must be freed */ - HICON hiconNotifyIcon; - - /* Palette management */ - ColormapPtr pcmapInstalled; - - /* Pointer to the root visual so we only have to look it up once */ - VisualPtr pRootVisual; - - /* 3 button emulation variables */ - int iE3BCachedPress; - Bool fE3BFakeButton2Sent; - - /* Privates used by shadow fb GDI engine */ - HBITMAP hbmpShadow; - HDC hdcScreen; - HDC hdcShadow; - HWND hwndScreen; - BITMAPINFOHEADER *pbmih; - - /* Privates used by shadow fb DirectDraw Nonlocking engine */ - LPDIRECTDRAW pdd; - LPDIRECTDRAW4 pdd4; - LPDIRECTDRAWSURFACE4 pddsShadow4; - LPDIRECTDRAWSURFACE4 pddsPrimary4; - LPDIRECTDRAWCLIPPER pddcPrimary; - BOOL fRetryCreateSurface; - - /* Privates used by multi-window */ - pthread_t ptWMProc; - pthread_t ptXMsgProc; - void *pWMInfo; - Bool fRootWindowShown; - - /* Privates used for any module running in a separate thread */ - pthread_mutex_t pmServerStarted; - Bool fServerStarted; - - /* Engine specific functions */ - winAllocateFBProcPtr pwinAllocateFB; - winFreeFBProcPtr pwinFreeFB; - winShadowUpdateProcPtr pwinShadowUpdate; - winInitScreenProcPtr pwinInitScreen; - winCloseScreenProcPtr pwinCloseScreen; - winInitVisualsProcPtr pwinInitVisuals; - winAdjustVideoModeProcPtr pwinAdjustVideoMode; - winCreateBoundingWindowProcPtr pwinCreateBoundingWindow; - winFinishScreenInitProcPtr pwinFinishScreenInit; - winBltExposedRegionsProcPtr pwinBltExposedRegions; - winBltExposedWindowRegionProcPtr pwinBltExposedWindowRegion; - winActivateAppProcPtr pwinActivateApp; - winRedrawScreenProcPtr pwinRedrawScreen; - winRealizeInstalledPaletteProcPtr pwinRealizeInstalledPalette; - winInstallColormapProcPtr pwinInstallColormap; - winStoreColorsProcPtr pwinStoreColors; - winCreateColormapProcPtr pwinCreateColormap; - winDestroyColormapProcPtr pwinDestroyColormap; - winCreatePrimarySurfaceProcPtr pwinCreatePrimarySurface; - winReleasePrimarySurfaceProcPtr pwinReleasePrimarySurface; - winCreateScreenResourcesProc pwinCreateScreenResources; - - /* 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; - ModifyPixmapHeaderProcPtr ModifyPixmapHeader; - - winCursorRec cursor; - - Bool fNativeGlActive; -} winPrivScreenRec; - -typedef struct { - void *value; - XID id; -} WindowIDPairRec, *WindowIDPairPtr; - -/* - * Extern declares for general global variables - */ - -#include "winglobals.h" - -extern winScreenInfo *g_ScreenInfo; -extern miPointerScreenFuncRec g_winPointerCursorFuncs; -extern DWORD g_dwEvents; - -#ifdef HAS_DEVWINDOWS -extern int g_fdMessageQueue; -#endif -extern DevPrivateKeyRec g_iScreenPrivateKeyRec; - -#define g_iScreenPrivateKey (&g_iScreenPrivateKeyRec) -extern DevPrivateKeyRec g_iCmapPrivateKeyRec; - -#define g_iCmapPrivateKey (&g_iCmapPrivateKeyRec) -extern DevPrivateKeyRec g_iGCPrivateKeyRec; - -#define g_iGCPrivateKey (&g_iGCPrivateKeyRec) -extern DevPrivateKeyRec g_iPixmapPrivateKeyRec; - -#define g_iPixmapPrivateKey (&g_iPixmapPrivateKeyRec) -extern DevPrivateKeyRec g_iWindowPrivateKeyRec; - -#define g_iWindowPrivateKey (&g_iWindowPrivateKeyRec) - -extern unsigned long g_ulServerGeneration; -extern DWORD g_dwEnginesSupported; -extern HINSTANCE g_hInstance; -extern int g_copyROP[]; -extern int g_patternROP[]; -extern const char *g_pszQueryHost; -extern DeviceIntPtr g_pwinPointer; -extern DeviceIntPtr g_pwinKeyboard; - -/* - * Extern declares for dynamically loaded library function pointers - */ - -extern FARPROC g_fpDirectDrawCreate; -extern FARPROC g_fpDirectDrawCreateClipper; - -/* - * Screen privates macros - */ - -#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \ - dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey)) - -#define winSetScreenPriv(pScreen,v) \ - dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v) - -#define winScreenPriv(pScreen) \ - winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen) - -/* - * Colormap privates macros - */ - -#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \ - dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey)) - -#define winSetCmapPriv(pCmap,v) \ - dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v) - -#define winCmapPriv(pCmap) \ - winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap) - -/* - * GC privates macros - */ - -#define winGetGCPriv(pGC) ((winPrivGCPtr) \ - dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey)) - -#define winSetGCPriv(pGC,v) \ - dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v) - -#define winGCPriv(pGC) \ - winPrivGCPtr pGCPriv = winGetGCPriv(pGC) - -/* - * Pixmap privates macros - */ - -#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \ - dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey)) - -#define winSetPixmapPriv(pPixmap,v) \ - dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v) - -#define winPixmapPriv(pPixmap) \ - winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap) - -/* - * Window privates macros - */ - -#define winGetWindowPriv(pWin) ((winPrivWinPtr) \ - dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey)) - -#define winSetWindowPriv(pWin,v) \ - dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v) - -#define winWindowPriv(pWin) \ - winPrivWinPtr pWinPriv = winGetWindowPriv(pWin) - -/* - * wrapper macros - */ -#define _WIN_WRAP(priv, real, mem, func) {\ - priv->mem = real->mem; \ - real->mem = func; \ -} - -#define _WIN_UNWRAP(priv, real, mem) {\ - real->mem = priv->mem; \ -} - -#define WIN_WRAP(mem, func) _WIN_WRAP(pScreenPriv, pScreen, mem, func) - -#define WIN_UNWRAP(mem) _WIN_UNWRAP(pScreenPriv, pScreen, mem) - -/* - * BEGIN DDX and DIX Function Prototypes - */ - -/* - * winallpriv.c - */ - -Bool - winAllocatePrivates(ScreenPtr pScreen); - -Bool - winInitCmapPrivates(ColormapPtr pCmap, int i); - -Bool - winAllocateCmapPrivates(ColormapPtr pCmap); - -/* - * winblock.c - */ - -void - -winBlockHandler(ScreenPtr pScreen, void *pTimeout); - -/* - * winclipboardinit.c - */ - -Bool - winInitClipboard(void); - -void - winClipboardShutdown(void); - -/* - * wincmap.c - */ - -void - winSetColormapFunctions(ScreenPtr pScreen); - -Bool - winCreateDefColormap(ScreenPtr pScreen); - -/* - * wincreatewnd.c - */ - -Bool - winCreateBoundingWindowFullScreen(ScreenPtr pScreen); - -Bool - winCreateBoundingWindowWindowed(ScreenPtr pScreen); - -/* - * windialogs.c - */ - -void - winDisplayExitDialog(winPrivScreenPtr pScreenPriv); - -void - winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv); - -void - winDisplayAboutDialog(winPrivScreenPtr pScreenPriv); - -/* - * winengine.c - */ - -void - winDetectSupportedEngines(void); - -Bool - winSetEngine(ScreenPtr pScreen); - -Bool - winGetDDProcAddresses(void); - -void - winReleaseDDProcAddresses(void); - -/* - * winerror.c - */ - -#ifdef DDXOSVERRORF -void -OsVendorVErrorF(const char *pszFormat, va_list va_args) -_X_ATTRIBUTE_PRINTF(1, 0); -#endif - -void -winMessageBoxF(const char *pszError, UINT uType, ...) -_X_ATTRIBUTE_PRINTF(1, 3); - -/* - * winglobals.c - */ - -void - winInitializeGlobals(void); - -/* - * winkeybd.c - */ - -int - winTranslateKey(WPARAM wParam, LPARAM lParam); - -int - winKeybdProc(DeviceIntPtr pDeviceInt, int iState); - -void - winInitializeModeKeyStates(void); - -void - winRestoreModeKeyStates(void); - -Bool - winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam); - -void - winKeybdReleaseKeys(void); - -void - winSendKeyEvent(DWORD dwKey, Bool fDown); - -BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam); - -void - winFixShiftKeys(int iScanCode); - -/* - * winkeyhook.c - */ - -Bool - winInstallKeyboardHookLL(void); - -void - winRemoveKeyboardHookLL(void); - -/* - * winmisc.c - */ - -CARD8 - winCountBits(DWORD dw); - -Bool - winUpdateFBPointer(ScreenPtr pScreen, void *pbits); - -/* - * winmouse.c - */ - -int - winMouseProc(DeviceIntPtr pDeviceInt, int iState); - -int - winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown); - -void - winMouseButtonsSendEvent(int iEventType, int iButton); - -int - -winMouseButtonsHandle(ScreenPtr pScreen, - int iEventType, int iButton, WPARAM wParam); - -void - winEnqueueMotion(int x, int y); - -/* - * winscrinit.c - */ - -Bool - winScreenInit(ScreenPtr pScreen, int argc, char **argv); - -Bool - winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv); - -/* - * winshadddnl.c - */ - -Bool - winSetEngineFunctionsShadowDDNL(ScreenPtr pScreen); - -/* - * winshadgdi.c - */ - -Bool - winSetEngineFunctionsShadowGDI(ScreenPtr pScreen); - -/* - * winwakeup.c - */ - -void -winWakeupHandler(ScreenPtr pScreen, int iResult); - -/* - * winwindow.c - */ - -Bool - winCreateWindowRootless(WindowPtr pWindow); - -Bool - winDestroyWindowRootless(WindowPtr pWindow); - -Bool - winPositionWindowRootless(WindowPtr pWindow, int x, int y); - -Bool - winChangeWindowAttributesRootless(WindowPtr pWindow, unsigned long mask); - -Bool - winUnmapWindowRootless(WindowPtr pWindow); - -Bool - winMapWindowRootless(WindowPtr pWindow); - -void - winSetShapeRootless(WindowPtr pWindow, int kind); - -/* - * winmultiwindowshape.c - */ - -void - winReshapeMultiWindow(WindowPtr pWin); - -void - winSetShapeMultiWindow(WindowPtr pWindow, int kind); - -void - winUpdateRgnMultiWindow(WindowPtr pWindow); - -/* - * winmultiwindowwindow.c - */ - -Bool - winCreateWindowMultiWindow(WindowPtr pWindow); - -Bool - winDestroyWindowMultiWindow(WindowPtr pWindow); - -Bool - winPositionWindowMultiWindow(WindowPtr pWindow, int x, int y); - -Bool - winChangeWindowAttributesMultiWindow(WindowPtr pWindow, unsigned long mask); - -Bool - winUnmapWindowMultiWindow(WindowPtr pWindow); - -Bool - winMapWindowMultiWindow(WindowPtr pWindow); - -void - winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent); - -void - winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib); - -void - winReorderWindowsMultiWindow(void); - -void - -winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w, - unsigned int h, WindowPtr pSib); -void - -winMoveWindowMultiWindow(WindowPtr pWin, int x, int y, - WindowPtr pSib, VTKind kind); - -void - -winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt, - RegionPtr oldRegion); - -PixmapPtr -winCreatePixmapMultiwindow(ScreenPtr pScreen, int width, int height, int depth, - unsigned usage_hint); -Bool -winDestroyPixmapMultiwindow(PixmapPtr pPixmap); - -Bool -winModifyPixmapHeaderMultiwindow(PixmapPtr pPixmap, - int width, - int height, - int depth, - int bitsPerPixel, int devKind, void *pPixData); - -XID - winGetWindowID(WindowPtr pWin); - -int - winAdjustXWindow(WindowPtr pWin, HWND hwnd); - -/* - * winmultiwindowwndproc.c - */ - -LRESULT CALLBACK -winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -/* - * wintrayicon.c - */ - -void - winInitNotifyIcon(winPrivScreenPtr pScreenPriv); - -void - winDeleteNotifyIcon(winPrivScreenPtr pScreenPriv); - -LRESULT -winHandleIconMessage(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam, - winPrivScreenPtr pScreenPriv); - -/* - * winwndproc.c - */ - -LRESULT CALLBACK -winWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - -/* - * winwindowswm.c - */ - -void - -winWindowsWMSendEvent(int type, unsigned int mask, int which, int arg, - Window window, int x, int y, int w, int h); - -void - winWindowsWMExtensionInit(void); - -/* - * wincursor.c - */ - -Bool - winInitCursor(ScreenPtr pScreen); - -/* - * winprocarg.c - */ -void - winInitializeScreens(int maxscreens); - -/* - * winrandr.c - */ -Bool - winRandRInit(ScreenPtr pScreen); -void - -winDoRandRScreenSetSize(ScreenPtr pScreen, - CARD16 width, - CARD16 height, CARD32 mmWidth, CARD32 mmHeight); - -/* - * winmsgwindow.c - */ -Bool -winCreateMsgWindowThread(void); - -/* - * winos.c - */ -void -winOS(void); - -/* - * END DDX and DIX Function Prototypes - */ - -#endif /* _WIN_H_ */ diff --git a/hw/xwin/winSetAppUserModelID.c b/hw/xwin/winSetAppUserModelID.c deleted file mode 100644 index f9cb92cdd..000000000 --- a/hw/xwin/winSetAppUserModelID.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2011 Tobias Häußler - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <X11/Xlib.h> -#include <X11/Xproto.h> -#include <X11/Xwindows.h> -#include <pthread.h> -#include "winwindow.h" -#include "os.h" -#include "winmsg.h" - -#include <shlwapi.h> - -#define INITGUID -#include "initguid.h" -#include "propertystore.h" -#undef INITGUID - -static HMODULE g_hmodShell32Dll = NULL; -static SHGETPROPERTYSTOREFORWINDOWPROC g_pSHGetPropertyStoreForWindow = NULL; - -void -winPropertyStoreInit(void) -{ - /* - Load library and get function pointer to SHGetPropertyStoreForWindow() - - SHGetPropertyStoreForWindow is only supported since Windows 7. On previous - versions the pointer will be NULL and taskbar grouping is not supported. - winSetAppUserModelID() will do nothing in this case. - */ - g_hmodShell32Dll = LoadLibrary("shell32.dll"); - if (g_hmodShell32Dll == NULL) { - ErrorF("winPropertyStoreInit - Could not load shell32.dll\n"); - return; - } - - g_pSHGetPropertyStoreForWindow = - (SHGETPROPERTYSTOREFORWINDOWPROC) GetProcAddress(g_hmodShell32Dll, - "SHGetPropertyStoreForWindow"); - if (g_pSHGetPropertyStoreForWindow == NULL) { - ErrorF - ("winPropertyStoreInit - Could not get SHGetPropertyStoreForWindow address\n"); - return; - } -} - -void -winPropertyStoreDestroy(void) -{ - if (g_hmodShell32Dll != NULL) { - FreeLibrary(g_hmodShell32Dll); - g_hmodShell32Dll = NULL; - g_pSHGetPropertyStoreForWindow = NULL; - } -} - -void -winSetAppUserModelID(HWND hWnd, const char *AppID) -{ - PROPVARIANT pv; - IPropertyStore *pps = NULL; - HRESULT hr; - - if (g_pSHGetPropertyStoreForWindow == NULL) { - return; - } - - winDebug("winSetAppUserMOdelID - hwnd 0x%p appid '%s'\n", hWnd, AppID); - - hr = g_pSHGetPropertyStoreForWindow(hWnd, &IID_IPropertyStore, - (void **) &pps); - if (SUCCEEDED(hr) && pps) { - memset(&pv, 0, sizeof(PROPVARIANT)); - if (AppID) { - pv.vt = VT_LPWSTR; - hr = SHStrDupA(AppID, &pv.pwszVal); - } - - if (SUCCEEDED(hr)) { - pps->lpVtbl->SetValue(pps, &PKEY_AppUserModel_ID, &pv); - PropVariantClear(&pv); - } - pps->lpVtbl->Release(pps); - } -} diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c deleted file mode 100644 index 818805cb1..000000000 --- a/hw/xwin/winallpriv.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: 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; - -#if CYGDEBUG - winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %lu " - "serverGeneration: %lu\n", g_ulServerGeneration, serverGeneration); -#endif - - /* 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 = malloc(sizeof(winPrivScreenRec)); - if (!pScreenPriv) { - ErrorF("winAllocateScreenPrivates - malloc () failed\n"); - return FALSE; - } - - /* Initialize the memory of the private structure */ - ZeroMemory(pScreenPriv, sizeof(winPrivScreenRec)); - - /* Initialize private structure members */ - pScreenPriv->fActive = TRUE; - - /* Register our screen private */ - if (!dixRegisterPrivateKey(g_iScreenPrivateKey, PRIVATE_SCREEN, 0)) { - ErrorF("winAllocatePrivates - AllocateScreenPrivate () failed\n"); - return FALSE; - } - - /* Save the screen private pointer */ - winSetScreenPriv(pScreen, pScreenPriv); - - /* 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 i) -{ -#if CYGDEBUG - winDebug("winInitCmapPrivates\n"); -#endif - - /* - * 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; - -#if CYGDEBUG - winDebug("winAllocateCmapPrivates\n"); -#endif - - /* 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 = 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); - -#if CYGDEBUG - winDebug("winAllocateCmapPrivates - Returning\n"); -#endif - - return TRUE; -} diff --git a/hw/xwin/winauth.c b/hw/xwin/winauth.c deleted file mode 100644 index 4e1b26d13..000000000 --- a/hw/xwin/winauth.c +++ /dev/null @@ -1,144 +0,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 "winauth.h" -#include "winmsg.h" - -/* Includes for authorization */ -#include "securitysrv.h" -#include "os/osdep.h" - -#include <xcb/xcb.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; -static xcb_auth_info_t auth_info; - -/* - * Code to generate a MIT-MAGIC-COOKIE-1, copied from under XCSECURITY - */ - -#ifndef XCSECURITY -static XID -GenerateAuthorization(unsigned name_length, - const char *name, - unsigned data_length, - const 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) -{ -#ifdef XCSECURITY - SecurityAuthorizationPtr pAuth = NULL; -#endif - - /* 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"); - return FALSE; - } - - else { - winDebug("winGenerateAuthorization - GenerateAuthorization success!\n" - "AuthDataLen: %d AuthData: %s\n", - g_uiAuthDataLen, g_pAuthData); - } - - auth_info.name = strdup(AUTH_NAME); - auth_info.namelen = strlen(AUTH_NAME); - auth_info.data = g_pAuthData; - auth_info.datalen = g_uiAuthDataLen; - -#ifdef XCSECURITY - /* Allocate structure for additional auth information */ - pAuth = (SecurityAuthorizationPtr) - malloc(sizeof(SecurityAuthorizationRec)); - if (!(pAuth)) { - ErrorF("winGenerateAuthorization - Failed allocating " - "SecurityAuthorizationPtr.\n"); - return FALSE; - } - - /* 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"); - return FALSE; - } -#endif - - return TRUE; -} - -xcb_auth_info_t * -winGetXcbAuthInfo(void) -{ - if (g_pAuthData) - return &auth_info; - - return NULL; -} diff --git a/hw/xwin/winauth.h b/hw/xwin/winauth.h deleted file mode 100644 index 97cfe52a1..000000000 --- a/hw/xwin/winauth.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include <xcb/xcb.h> -#include <X11/Xmd.h> // for BOOL - -BOOL winGenerateAuthorization(void); -xcb_auth_info_t * winGetXcbAuthInfo(void); diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c deleted file mode 100644 index c8eb0c9a1..000000000 --- a/hw/xwin/winblock.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - *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(ScreenPtr pScreen, void *pTimeout) -{ - winScreenPriv(pScreen); - -#ifndef HAS_DEVWINDOWS - struct timeval **tvp = pTimeout; - - if (*tvp != NULL) { - if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) { - /* If there are still messages to process on the Windows message - queue, make sure select() just polls rather than blocking. - */ - (*tvp)->tv_sec = 0; - (*tvp)->tv_usec = 0; - } - else { - /* Otherwise, lacking /dev/windows, we must wake up again in - a reasonable time to check the Windows message queue. without - noticeable delay. - */ - (*tvp)->tv_sec = 0; - (*tvp)->tv_usec = 100; - } - } -#endif - - /* Signal threaded modules to begin */ - if (pScreenPriv != NULL && !pScreenPriv->fServerStarted) { - int iReturn; - - winDebug("winBlockHandler - pthread_mutex_unlock()\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); - } - else { - winDebug("winBlockHandler - pthread_mutex_unlock () returned\n"); - } - } - - /* - At least one X client has asked to suspend the screensaver, so - reset Windows' display idle timer - */ -#ifdef SCREENSAVER - if (screenSaverSuspended) - SetThreadExecutionState(ES_DISPLAY_REQUIRED); -#endif -} diff --git a/hw/xwin/winclipboard/debug.c b/hw/xwin/winclipboard/debug.c deleted file mode 100644 index 78ab6d902..000000000 --- a/hw/xwin/winclipboard/debug.c +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright © Jon TURNEY 2013 -// -// This file is part of xwinclip. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice (including the next -// paragraph) shall be included in all copies or substantial portions of the -// Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - -#include <stdarg.h> -#include <stdio.h> - -#if 1 -int -winDebug(const char *format, ...) -{ - int count; - va_list ap; - va_start(ap, format); - count = fprintf(stderr, "xwinclip: "); - count += vfprintf(stderr, format, ap); - va_end(ap); - return count; -} -#endif - -int -ErrorF(const char *format, ...) -{ - int count; - va_list ap; - va_start(ap, format); - count = vfprintf(stderr, format, ap); - va_end(ap); - return count; -} diff --git a/hw/xwin/winclipboard/internal.h b/hw/xwin/winclipboard/internal.h deleted file mode 100644 index 368fa7057..000000000 --- a/hw/xwin/winclipboard/internal.h +++ /dev/null @@ -1,119 +0,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 - */ - -#ifndef WINCLIPBOARD_INTERNAL_H -#define WINCLIPBOARD_INTERNAL_H - -#include <xcb/xproto.h> -#include <X11/Xfuncproto.h> // for _X_ATTRIBUTE_PRINTF -#include <X11/Xmd.h> // for BOOL - -/* Windows headers */ -#include <X11/Xwindows.h> - -#define WIN_XEVENTS_SUCCESS 0 // more like 'CONTINUE' -#define WIN_XEVENTS_FAILED 1 -#define WIN_XEVENTS_NOTIFY_DATA 3 -#define WIN_XEVENTS_NOTIFY_TARGETS 4 - -#define WM_WM_QUIT (WM_USER + 2) - -#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) - -/* - * References to external symbols - */ - -extern void winDebug(const char *format, ...) _X_ATTRIBUTE_PRINTF(1, 2); -extern void ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1, 2); - -/* - * winclipboardtextconv.c - */ - -void - winClipboardDOStoUNIX(char *pszData, int iLength); - -void - winClipboardUNIXtoDOS(char **ppszData, int iLength); - -/* - * winclipboardthread.c - */ - -typedef struct -{ - xcb_atom_t atomClipboard; - xcb_atom_t atomLocalProperty; - xcb_atom_t atomUTF8String; - xcb_atom_t atomCompoundText; - xcb_atom_t atomTargets; - xcb_atom_t atomIncr; -} ClipboardAtoms; - -/* - * winclipboardwndproc.c - */ - -BOOL winClipboardFlushWindowsMessageQueue(HWND hwnd); - -LRESULT CALLBACK -winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -typedef struct -{ - xcb_connection_t *pClipboardDisplay; - xcb_window_t iClipboardWindow; - ClipboardAtoms *atoms; -} ClipboardWindowCreationParams; - -/* - * winclipboardxevents.c - */ - -typedef struct -{ - xcb_atom_t *targetList; - unsigned char *incr; - unsigned long int incrsize; -} ClipboardConversionData; - -int -winClipboardFlushXEvents(HWND hwnd, - xcb_window_t iWindow, xcb_connection_t * pDisplay, - ClipboardConversionData *data, ClipboardAtoms *atoms); - -xcb_atom_t -winClipboardGetLastOwnedSelectionAtom(ClipboardAtoms *atoms); - -void -winClipboardInitMonitoredSelections(void); - -#endif diff --git a/hw/xwin/winclipboard/meson.build b/hw/xwin/winclipboard/meson.build deleted file mode 100644 index 8db06a485..000000000 --- a/hw/xwin/winclipboard/meson.build +++ /dev/null @@ -1,42 +0,0 @@ -srcs_windows_clipboard = [ - 'winclipboard.h', - 'textconv.c', - 'thread.c', - 'wndproc.c', - 'xevents.c', -] - -xwin_clipboard = static_library( - 'XWinclipboard', - srcs_windows_clipboard, - include_directories: inc, - c_args: '-DHAVE_XWIN_CONFIG_H', - dependencies: [ - dependency('xcb'), - dependency('xcb-aux'), - dependency('xcb-icccm'), - dependency('xcb-xfixes'), - socket_dep, - ], -) - -srcs_xwinclip = [ - 'xwinclip.c', - 'debug.c', -] - -executable( - 'xwinclip', - srcs_xwinclip, - dependencies: dependency('xcb'), - link_with: xwin_clipboard, - link_args: ['-lgdi32', '-lpthread'], - install: true, -) - -xwinclip_man = configure_file( - input: 'xwinclip.man', - output: 'xwinclip.1', - configuration: manpage_config, -) -install_man(xwinclip_man) diff --git a/hw/xwin/winclipboard/textconv.c b/hw/xwin/winclipboard/textconv.c deleted file mode 100644 index 651ccc666..000000000 --- a/hw/xwin/winclipboard/textconv.c +++ /dev/null @@ -1,142 +0,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 <stdlib.h> -#include "internal.h" - -/* - * Convert \r\n to \n - * - * NOTE: This was heavily inspired by, Cygwin's - * winsup/cygwin/fhandler.cc/fhandler_base::read () - */ - -void -winClipboardDOStoUNIX(char *pszSrc, int iLength) -{ - char *pszDest = pszSrc; - char *pszEnd = pszSrc + iLength; - - /* Loop until the last character */ - while (pszSrc < pszEnd) { - /* Copy the current source character to current destination character */ - *pszDest = *pszSrc; - - /* Advance to the next source character */ - pszSrc++; - - /* Don't advance the destination character if we need to drop an \r */ - if (*pszDest != '\r' || *pszSrc != '\n') - pszDest++; - } - - /* Move the terminating null */ - *pszDest = '\0'; -} - -/* - * Convert \n to \r\n - */ - -void -winClipboardUNIXtoDOS(char **ppszData, int iLength) -{ - int iNewlineCount = 0; - char *pszSrc = *ppszData; - char *pszEnd = pszSrc + iLength; - char *pszDest = NULL, *pszDestBegin = NULL; - - winDebug("UNIXtoDOS () - Original data:'%s'\n", *ppszData); - - /* Count \n characters without leading \r */ - while (pszSrc < pszEnd) { - /* Skip ahead two character if found set of \r\n */ - if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') { - pszSrc += 2; - continue; - } - - /* Increment the count if found naked \n */ - if (*pszSrc == '\n') { - iNewlineCount++; - } - - pszSrc++; - } - - /* Return if no naked \n's */ - if (iNewlineCount == 0) - return; - - /* Allocate a new string */ - pszDestBegin = pszDest = malloc(iLength + iNewlineCount + 1); - - /* Set source pointer to beginning of data string */ - pszSrc = *ppszData; - - /* Loop through all characters in source string */ - while (pszSrc < pszEnd) { - /* Copy line endings that are already valid */ - if (*pszSrc == '\r' && pszSrc + 1 < pszEnd && *(pszSrc + 1) == '\n') { - *pszDest = *pszSrc; - *(pszDest + 1) = *(pszSrc + 1); - pszDest += 2; - pszSrc += 2; - continue; - } - - /* Add \r to naked \n's */ - if (*pszSrc == '\n') { - *pszDest = '\r'; - *(pszDest + 1) = *pszSrc; - pszDest += 2; - pszSrc += 1; - continue; - } - - /* Copy normal characters */ - *pszDest = *pszSrc; - pszSrc++; - pszDest++; - } - - /* Put terminating null at end of new string */ - *pszDest = '\0'; - - /* Swap string pointers */ - free(*ppszData); - *ppszData = pszDestBegin; - - winDebug("UNIXtoDOS () - Final string:'%s'\n", pszDestBegin); -} diff --git a/hw/xwin/winclipboard/thread.c b/hw/xwin/winclipboard/thread.c deleted file mode 100644 index 0e60c1b24..000000000 --- a/hw/xwin/winclipboard/thread.c +++ /dev/null @@ -1,439 +0,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 <assert.h> -#include <unistd.h> -#include <fcntl.h> -#include <pthread.h> -#include <sys/param.h> // for MAX() macro - -#ifdef HAS_WINSOCK -#include <X11/Xwinsock.h> -#else -#include <errno.h> -#endif - -#include <xcb/xcb.h> -#include <xcb/xcb_aux.h> -#include <xcb/xcb_icccm.h> -#include <xcb/xfixes.h> - -#include "winclipboard.h" -#include "internal.h" - -#define WIN_CONNECT_RETRIES 40 -#define WIN_CONNECT_DELAY 4 - -#define WIN_CLIPBOARD_WINDOW_CLASS "xwinclip" -#define WIN_CLIPBOARD_WINDOW_TITLE "xwinclip" -#ifdef HAS_DEVWINDOWS -#define WIN_MSG_QUEUE_FNAME "/dev/windows" -#endif - -/* - * Global variables - */ - -static HWND g_hwndClipboard = NULL; - -int xfixes_event_base; -int xfixes_error_base; - -/* - * Local function prototypes - */ - -static HWND -winClipboardCreateMessagingWindow(xcb_connection_t *conn, xcb_window_t iWindow, ClipboardAtoms *atoms); - -static xcb_atom_t -intern_atom(xcb_connection_t *conn, const char *atomName) -{ - xcb_intern_atom_reply_t *atom_reply; - xcb_intern_atom_cookie_t atom_cookie; - xcb_atom_t atom = XCB_ATOM_NONE; - - atom_cookie = xcb_intern_atom(conn, 0, strlen(atomName), atomName); - atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL); - if (atom_reply) { - atom = atom_reply->atom; - free(atom_reply); - } - return atom; -} - -/* - * Create X11 and Win32 messaging windows, and run message processing loop - * - * returns TRUE if shutdown was signalled to loop, FALSE if some error occurred - */ - -BOOL -winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info) -{ - ClipboardAtoms atoms; - int iReturn; - HWND hwnd = NULL; - int iConnectionNumber = 0; -#ifdef HAS_DEVWINDOWS - int fdMessageQueue = 0; -#else - struct timeval tvTimeout; -#endif - fd_set fdsRead; - int iMaxDescriptor; - xcb_connection_t *conn; - xcb_window_t iWindow = XCB_NONE; - int iSelectError; - BOOL fShutdown = FALSE; - ClipboardConversionData data; - int screen; - - winDebug("winClipboardProc - Hello\n"); - - /* Make sure that the display opened */ - conn = xcb_connect_to_display_with_auth_info(szDisplay, auth_info, &screen); - if (xcb_connection_has_error(conn)) { - ErrorF("winClipboardProc - Failed opening the display, giving up\n"); - goto winClipboardProc_Done; - } - - ErrorF("winClipboardProc - xcb_connect () returned and " - "successfully opened the display.\n"); - - /* Get our connection number */ - iConnectionNumber = xcb_get_file_descriptor(conn); - -#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); - goto winClipboardProc_Done; - } - - /* Find max of our file descriptors */ - iMaxDescriptor = MAX(fdMessageQueue, iConnectionNumber) + 1; -#else - iMaxDescriptor = iConnectionNumber + 1; -#endif - - const xcb_query_extension_reply_t *xfixes_query; - xfixes_query = xcb_get_extension_data(conn, &xcb_xfixes_id); - if (!xfixes_query->present) - ErrorF ("winClipboardProc - XFixes extension not present\n"); - xfixes_event_base = xfixes_query->first_event; - xfixes_error_base = xfixes_query->first_error; - /* Must advise server of XFIXES version we require */ - xcb_xfixes_query_version_unchecked(conn, 1, 0); - - /* Create atoms */ - atoms.atomClipboard = intern_atom(conn, "CLIPBOARD"); - atoms.atomLocalProperty = intern_atom(conn, "CYGX_CUT_BUFFER"); - atoms.atomUTF8String = intern_atom(conn, "UTF8_STRING"); - atoms.atomCompoundText = intern_atom(conn, "COMPOUND_TEXT"); - atoms.atomTargets = intern_atom(conn, "TARGETS"); - atoms.atomIncr = intern_atom(conn, "INCR"); - - xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screen); - xcb_window_t root_window_id = root_screen->root; - - /* Create a messaging window */ - iWindow = xcb_generate_id(conn); - xcb_void_cookie_t cookie = xcb_create_window_checked(conn, - XCB_COPY_FROM_PARENT, - iWindow, - root_window_id, - 1, 1, - 500, 500, - 0, - XCB_WINDOW_CLASS_INPUT_ONLY, - XCB_COPY_FROM_PARENT, - 0, - NULL); - - xcb_generic_error_t *error; - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardProc - Could not create an X window.\n"); - free(error); - goto winClipboardProc_Done; - } - - xcb_icccm_set_wm_name(conn, iWindow, XCB_ATOM_STRING, 8, strlen("xwinclip"), "xwinclip"); - - /* Select event types to watch */ - const static uint32_t values[] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; - cookie = xcb_change_window_attributes_checked(conn, iWindow, XCB_CW_EVENT_MASK, values); - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardProc - Could not set event mask on messaging window\n"); - free(error); - } - - xcb_xfixes_select_selection_input(conn, - iWindow, - XCB_ATOM_PRIMARY, - XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | - XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | - XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE); - - xcb_xfixes_select_selection_input(conn, - iWindow, - atoms.atomClipboard, - XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | - XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | - XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE); - - /* Initialize monitored selection state */ - winClipboardInitMonitoredSelections(); - /* Create Windows messaging window */ - hwnd = winClipboardCreateMessagingWindow(conn, iWindow, &atoms); - - /* Save copy of HWND */ - g_hwndClipboard = hwnd; - - /* Assert ownership of selections if Win32 clipboard is owned */ - if (NULL != GetClipboardOwner()) { - /* PRIMARY */ - cookie = xcb_set_selection_owner_checked(conn, iWindow, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME); - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardProc - Could not set PRIMARY owner\n"); - free(error); - goto winClipboardProc_Done; - } - - /* CLIPBOARD */ - cookie = xcb_set_selection_owner_checked(conn, iWindow, atoms.atomClipboard, XCB_CURRENT_TIME); - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardProc - Could not set CLIPBOARD owner\n"); - free(error); - goto winClipboardProc_Done; - } - } - - data.incr = NULL; - data.incrsize = 0; - - /* Loop for events */ - while (1) { - - /* Process X events */ - winClipboardFlushXEvents(hwnd, iWindow, conn, &data, &atoms); - - /* Process Windows messages */ - if (!winClipboardFlushWindowsMessageQueue(hwnd)) { - ErrorF("winClipboardProc - winClipboardFlushWindowsMessageQueue trapped " - "WM_QUIT message, exiting main loop.\n"); - break; - } - - /* We need to ensure that all pending requests are sent */ - xcb_flush(conn); - - /* 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; - } - - if (FD_ISSET(iConnectionNumber, &fdsRead)) { - winDebug - ("winClipboardProc - X connection ready, pumping X event queue\n"); - } - -#ifdef HAS_DEVWINDOWS - /* Check for Windows event ready */ - if (FD_ISSET(fdMessageQueue, &fdsRead)) -#else - if (1) -#endif - { - winDebug - ("winClipboardProc - /dev/windows ready, pumping Windows message queue\n"); - } - -#ifdef HAS_DEVWINDOWS - if (!(FD_ISSET(iConnectionNumber, &fdsRead)) && - !(FD_ISSET(fdMessageQueue, &fdsRead))) { - winDebug("winClipboardProc - Spurious wake, select() returned %d\n", iReturn); - } -#endif - } - - /* broke out of while loop on a shutdown message */ - fShutdown = TRUE; - - winClipboardProc_Done: - /* Close our Windows window */ - if (g_hwndClipboard) { - DestroyWindow(g_hwndClipboard); - } - - /* Close our X window */ - if (!xcb_connection_has_error(conn) && iWindow) { - cookie = xcb_destroy_window_checked(conn, iWindow); - if ((error = xcb_request_check(conn, cookie))) - ErrorF("winClipboardProc - XDestroyWindow failed.\n"); - else - ErrorF("winClipboardProc - XDestroyWindow succeeded.\n"); - free(error); - } - -#ifdef HAS_DEVWINDOWS - /* Close our Win32 message handle */ - if (fdMessageQueue) - close(fdMessageQueue); -#endif - - /* - * xcb_disconnect() does not sync, so is safe to call even when we are built - * into the server. Unlike XCloseDisplay() there will be no deadlock if the - * server is in the process of exiting and waiting for this thread to exit. - */ - if (!xcb_connection_has_error(conn)) { - /* Close our X display */ - xcb_disconnect(conn); - } - - /* global clipboard variable reset */ - g_hwndClipboard = NULL; - - return fShutdown; -} - -/* - * Create the Windows window that we use to receive Windows messages - */ - -static HWND -winClipboardCreateMessagingWindow(xcb_connection_t *conn, xcb_window_t iWindow, ClipboardAtoms *atoms) -{ - WNDCLASSEX wc; - ClipboardWindowCreationParams cwcp; - 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); - - /* Information to be passed to WM_CREATE */ - cwcp.pClipboardDisplay = conn; - cwcp.iClipboardWindow = iWindow; - cwcp.atoms = atoms; - - /* 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 */ - &cwcp); /* 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 -winClipboardWindowDestroy(void) -{ - if (g_hwndClipboard) { - SendMessage(g_hwndClipboard, WM_WM_QUIT, 0, 0); - } -} diff --git a/hw/xwin/winclipboard/winclipboard.h b/hw/xwin/winclipboard/winclipboard.h deleted file mode 100644 index 243aa24dc..000000000 --- a/hw/xwin/winclipboard/winclipboard.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright © Jon TURNEY 2013 -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice (including the next -// paragraph) shall be included in all copies or substantial portions of the -// Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File: winclipboard.h -// Purpose: public interface to winclipboard library -// - -#ifndef WINCLIPBOARD_H -#define WINCLIPBOARD_H - -#include <xcb/xcb.h> -#include <X11/Xmd.h> // for BOOL type - -BOOL winClipboardProc(char *szDisplay, xcb_auth_info_t *auth_info); - -void winFixClipboardChain(void); - -void winClipboardWindowDestroy(void); - -extern BOOL fPrimarySelection; - -#endif diff --git a/hw/xwin/winclipboard/wndproc.c b/hw/xwin/winclipboard/wndproc.c deleted file mode 100644 index 63de4b9e5..000000000 --- a/hw/xwin/winclipboard/wndproc.c +++ /dev/null @@ -1,462 +0,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 - */ - -#define WINVER 0x0600 - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <sys/types.h> -#include <sys/time.h> -#include <limits.h> - -#include <xcb/xproto.h> -#include <xcb/xcb_aux.h> - -#include "internal.h" -#include "winclipboard.h" - -/* - * Constants - */ - -#define WIN_POLL_TIMEOUT 1 - -/* - * Process X events up to specified timeout - */ - -static int -winProcessXEventsTimeout(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn, - ClipboardConversionData *data, ClipboardAtoms *atoms, int iTimeoutSec) -{ - int iConnNumber; - struct timeval tv; - int iReturn; - - winDebug("winProcessXEventsTimeout () - pumping X events, timeout %d seconds\n", - iTimeoutSec); - - /* Get our connection number */ - iConnNumber = xcb_get_file_descriptor(conn); - - /* Loop for X events */ - while (1) { - fd_set fdsRead; - long remainingTime; - - /* Process X events */ - iReturn = winClipboardFlushXEvents(hwnd, iWindow, conn, data, atoms); - - winDebug("winProcessXEventsTimeout () - winClipboardFlushXEvents returned %d\n", iReturn); - - if ((WIN_XEVENTS_NOTIFY_DATA == iReturn) || (WIN_XEVENTS_NOTIFY_TARGETS == iReturn) || (WIN_XEVENTS_FAILED == iReturn)) { - /* Bail out */ - return iReturn; - } - - /* We need to ensure that all pending requests are sent */ - xcb_flush(conn); - - /* Setup the file descriptor set */ - FD_ZERO(&fdsRead); - FD_SET(iConnNumber, &fdsRead); - - /* Adjust timeout */ - remainingTime = iTimeoutSec * 1000; - tv.tv_sec = remainingTime / 1000; - tv.tv_usec = (remainingTime % 1000) * 1000; - - /* Break out if no time left */ - if (remainingTime <= 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); /* Timeout */ - if (iReturn < 0) { - ErrorF("winProcessXEventsTimeout - Call to select () failed: %d. " - "Bailing.\n", iReturn); - break; - } - - if (!FD_ISSET(iConnNumber, &fdsRead)) { - winDebug("winProcessXEventsTimeout - Spurious wake, select() returned %d\n", iReturn); - } - } - - return WIN_XEVENTS_SUCCESS; -} - -/* - * Process a given Windows message - */ - -LRESULT CALLBACK -winClipboardWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - static xcb_connection_t *conn; - static xcb_window_t iWindow; - static ClipboardAtoms *atoms; - static BOOL fRunning; - - /* Branch on message type */ - switch (message) { - case WM_DESTROY: - { - winDebug("winClipboardWindowProc - WM_DESTROY\n"); - - /* Remove clipboard listener */ - RemoveClipboardFormatListener(hwnd); - } - return 0; - - case WM_WM_QUIT: - { - winDebug("winClipboardWindowProc - WM_WM_QUIT\n"); - fRunning = FALSE; - PostQuitMessage(0); - } - return 0; - - case WM_CREATE: - { - ClipboardWindowCreationParams *cwcp = (ClipboardWindowCreationParams *)((CREATESTRUCT *)lParam)->lpCreateParams; - - winDebug("winClipboardWindowProc - WM_CREATE\n"); - - conn = cwcp->pClipboardDisplay; - iWindow = cwcp->iClipboardWindow; - atoms = cwcp->atoms; - fRunning = TRUE; - - AddClipboardFormatListener(hwnd); - } - return 0; - - case WM_CLIPBOARDUPDATE: - { - xcb_generic_error_t *error; - xcb_void_cookie_t cookie_set; - - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Enter\n"); - - /* - * NOTE: We cannot bail out when NULL == GetClipboardOwner () - * because some applications deal with the clipboard in a manner - * that causes the clipboard owner to be NULL when they are in - * fact taking ownership. One example of this is the Win32 - * native compile of emacs. - */ - - /* Bail when we still own the clipboard */ - if (hwnd == GetClipboardOwner()) { - - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "We own the clipboard, returning.\n"); - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n"); - - return 0; - } - - /* Bail when shutting down */ - if (!fRunning) - 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)) { - - xcb_get_selection_owner_cookie_t cookie_get; - xcb_get_selection_owner_reply_t *reply; - - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "Clipboard does not contain CF_TEXT nor " - "CF_UNICODETEXT.\n"); - - /* - * We need to make sure that the X Server has processed - * previous XSetSelectionOwner messages. - */ - xcb_aux_sync(conn); - - winDebug("winClipboardWindowProc - XSync done.\n"); - - /* Release PRIMARY selection if owned */ - cookie_get = xcb_get_selection_owner(conn, XCB_ATOM_PRIMARY); - reply = xcb_get_selection_owner_reply(conn, cookie_get, NULL); - if (reply) { - if (reply->owner == iWindow) { - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "PRIMARY selection is owned by us, releasing.\n"); - xcb_set_selection_owner(conn, XCB_NONE, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME); - } - free(reply); - } - - /* Release CLIPBOARD selection if owned */ - cookie_get = xcb_get_selection_owner(conn, atoms->atomClipboard); - reply = xcb_get_selection_owner_reply(conn, cookie_get, NULL); - if (reply) { - if (reply->owner == iWindow) { - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "CLIPBOARD selection is owned by us, releasing\n"); - xcb_set_selection_owner(conn, XCB_NONE, atoms->atomClipboard, XCB_CURRENT_TIME); - } - free(reply); - } - - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n"); - - return 0; - } - - /* Reassert ownership of PRIMARY */ - cookie_set = xcb_set_selection_owner_checked(conn, iWindow, XCB_ATOM_PRIMARY, XCB_CURRENT_TIME); - error = xcb_request_check(conn, cookie_set); - if (error) { - ErrorF("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "Could not reassert ownership of PRIMARY\n"); - free(error); - } else { - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "Reasserted ownership of PRIMARY\n"); - } - - /* Reassert ownership of the CLIPBOARD */ - cookie_set = xcb_set_selection_owner_checked(conn, iWindow, atoms->atomClipboard, XCB_CURRENT_TIME); - error = xcb_request_check(conn, cookie_set); - if (error) { - ErrorF("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "Could not reassert ownership of CLIPBOARD\n"); - free(error); - } - else { - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE - " - "Reasserted ownership of CLIPBOARD\n"); - } - - /* Flush the pending SetSelectionOwner event now */ - xcb_flush(conn); - } - winDebug("winClipboardWindowProc - WM_CLIPBOARDUPDATE: Exit\n"); - return 0; - - case WM_DESTROYCLIPBOARD: - /* - * NOTE: Intentionally do nothing. - * Changes in the Win32 clipboard are handled by WM_CLIPBOARDUPDATE - * 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_CLIPBOARDUPDATE 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_RENDERALLFORMATS: - winDebug("winClipboardWindowProc - WM_RENDERALLFORMATS - Hello.\n"); - - /* - WM_RENDERALLFORMATS is sent as we are shutting down, to render the - clipboard so its contents remains available to other applications. - - Unfortunately, this can't work without major changes. The server is - already waiting for us to stop, so we can't ask for the rendering of - clipboard text now. - */ - - return 0; - - case WM_RENDERFORMAT: - { - int iReturn; - BOOL pasted = FALSE; - xcb_atom_t selection; - ClipboardConversionData data; - int best_target = 0; - - winDebug("winClipboardWindowProc - WM_RENDERFORMAT %d - Hello.\n", - (int)wParam); - - selection = winClipboardGetLastOwnedSelectionAtom(atoms); - if (selection == XCB_NONE) { - ErrorF("winClipboardWindowProc - no monitored selection is owned\n"); - goto fake_paste; - } - - winDebug("winClipboardWindowProc - requesting targets for selection from owner\n"); - - /* Request the selection's supported conversion targets */ - xcb_convert_selection(conn, iWindow, selection, atoms->atomTargets, - atoms->atomLocalProperty, XCB_CURRENT_TIME); - - /* Process X events */ - data.incr = NULL; - data.incrsize = 0; - - iReturn = winProcessXEventsTimeout(hwnd, - iWindow, - conn, - &data, - atoms, - WIN_POLL_TIMEOUT); - - if (WIN_XEVENTS_NOTIFY_TARGETS != iReturn) { - ErrorF - ("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY_TARGETS\n"); - goto fake_paste; - } - - /* Choose the most preferred target */ - { - struct target_priority - { - xcb_atom_t target; - unsigned int priority; - }; - - struct target_priority target_priority_table[] = - { - { atoms->atomUTF8String, 0 }, - // { atoms->atomCompoundText, 1 }, not implemented (yet?) - { XCB_ATOM_STRING, 2 }, - }; - - int best_priority = INT_MAX; - - int i,j; - for (i = 0 ; data.targetList[i] != 0; i++) - { - for (j = 0; j < ARRAY_SIZE(target_priority_table); j ++) - { - if ((data.targetList[i] == target_priority_table[j].target) && - (target_priority_table[j].priority < best_priority)) - { - best_target = target_priority_table[j].target; - best_priority = target_priority_table[j].priority; - } - } - } - } - - free(data.targetList); - data.targetList = 0; - - winDebug("winClipboardWindowProc - best target is %d\n", best_target); - - /* No useful targets found */ - if (best_target == 0) - goto fake_paste; - - winDebug("winClipboardWindowProc - requesting selection from owner\n"); - - /* Request the selection contents */ - xcb_convert_selection(conn, iWindow, selection, best_target, - atoms->atomLocalProperty, XCB_CURRENT_TIME); - - /* Process X events */ - iReturn = winProcessXEventsTimeout(hwnd, - iWindow, - conn, - &data, - atoms, - WIN_POLL_TIMEOUT); - - /* - * winProcessXEventsTimeout had better have seen a notify event, - * or else we are dealing with a buggy or old X11 app. - */ - if (WIN_XEVENTS_NOTIFY_DATA != iReturn) { - ErrorF - ("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY_DATA\n"); - } - else { - pasted = TRUE; - } - - /* - * If we couldn't get the data from the X clipboard, we - * have to paste some fake data to the Win32 clipboard to - * satisfy the requirement that we write something to it. - */ - fake_paste: - if (!pasted) - { - /* Paste no data, to satisfy required call to SetClipboardData */ - SetClipboardData(CF_UNICODETEXT, NULL); - SetClipboardData(CF_TEXT, NULL); - } - - winDebug("winClipboardWindowProc - WM_RENDERFORMAT - Returning.\n"); - return 0; - } - } - - /* Let Windows perform default processing for unhandled messages */ - return DefWindowProc(hwnd, message, wParam, lParam); -} - -/* - * Process any pending Windows messages - */ - -BOOL -winClipboardFlushWindowsMessageQueue(HWND hwnd) -{ - MSG msg; - - /* Flush the messaging window queue */ - /* NOTE: Do not pass the hwnd of our messaging window to PeekMessage, - * as this will filter out many non-window-specific messages that - * are sent to our thread, such as WM_QUIT. - */ - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - /* Dispatch the message if not WM_QUIT */ - if (msg.message == WM_QUIT) - return FALSE; - else - DispatchMessage(&msg); - } - - return TRUE; -} diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c deleted file mode 100644 index cac17153f..000000000 --- a/hw/xwin/winclipboard/xevents.c +++ /dev/null @@ -1,829 +0,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> -#endif - -#include <limits.h> -#include <wchar.h> - -#include <xcb/xcb.h> -#include <xcb/xfixes.h> - -#include "winclipboard.h" -#include "internal.h" - -/* - * Constants - */ - -#define CLIP_NUM_SELECTIONS 2 -#define CLIP_OWN_NONE -1 -#define CLIP_OWN_PRIMARY 0 -#define CLIP_OWN_CLIPBOARD 1 - -#define CP_ISO_8559_1 28591 - -/* - * Global variables - */ - -extern int xfixes_event_base; -BOOL fPrimarySelection = TRUE; - -/* - * Local variables - */ - -static xcb_window_t s_iOwners[CLIP_NUM_SELECTIONS] = { XCB_NONE, XCB_NONE }; -static const char *szSelectionNames[CLIP_NUM_SELECTIONS] = - { "PRIMARY", "CLIPBOARD" }; - -static unsigned int lastOwnedSelectionIndex = CLIP_OWN_NONE; - -static void -MonitorSelection(xcb_xfixes_selection_notify_event_t * e, unsigned int i) -{ - /* Look for owned -> not owned transition */ - if ((XCB_NONE == e->owner) && (XCB_NONE != s_iOwners[i])) { - unsigned int other_index; - - winDebug("MonitorSelection - %s - Going from owned to not owned.\n", - szSelectionNames[i]); - - /* If this selection is not owned, the other monitored selection must be the most - recently owned, if it is owned at all */ - if (i == CLIP_OWN_PRIMARY) - other_index = CLIP_OWN_CLIPBOARD; - if (i == CLIP_OWN_CLIPBOARD) - other_index = CLIP_OWN_PRIMARY; - if (XCB_NONE != s_iOwners[other_index]) - lastOwnedSelectionIndex = other_index; - else - lastOwnedSelectionIndex = CLIP_OWN_NONE; - } - - /* Save last owned selection */ - if (XCB_NONE != e->owner) { - lastOwnedSelectionIndex = i; - } - - /* Save new selection owner or None */ - s_iOwners[i] = e->owner; - winDebug("MonitorSelection - %s - Now owned by XID %x\n", - szSelectionNames[i], e->owner); -} - -xcb_atom_t -winClipboardGetLastOwnedSelectionAtom(ClipboardAtoms *atoms) -{ - if (lastOwnedSelectionIndex == CLIP_OWN_NONE) - return XCB_NONE; - - if (lastOwnedSelectionIndex == CLIP_OWN_PRIMARY) - return XCB_ATOM_PRIMARY; - - if (lastOwnedSelectionIndex == CLIP_OWN_CLIPBOARD) - return atoms->atomClipboard; - - return XCB_NONE; -} - - -void -winClipboardInitMonitoredSelections(void) -{ - /* Initialize static variables */ - int i; - for (i = 0; i < CLIP_NUM_SELECTIONS; ++i) - s_iOwners[i] = XCB_NONE; - - lastOwnedSelectionIndex = CLIP_OWN_NONE; -} - -static char *get_atom_name(xcb_connection_t *conn, xcb_atom_t atom) -{ - char *ret; - xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name(conn, atom); - xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(conn, cookie, NULL); - if (!reply) - return NULL; - ret = malloc(xcb_get_atom_name_name_length(reply) + 1); - if (ret) { - memcpy(ret, xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply)); - ret[xcb_get_atom_name_name_length(reply)] = '\0'; - } - free(reply); - return ret; -} - -static int -winClipboardSelectionNotifyTargets(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn, ClipboardConversionData *data, ClipboardAtoms *atoms) -{ - /* Retrieve the selection data and delete the property */ - xcb_get_property_cookie_t cookie = xcb_get_property(conn, - TRUE, - iWindow, - atoms->atomLocalProperty, - XCB_GET_PROPERTY_TYPE_ANY, - 0, - INT_MAX); - xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL); - if (!reply) { - ErrorF("winClipboardFlushXEvents - SelectionNotify - " - "XGetWindowProperty () failed\n"); - } else { - xcb_atom_t *prop = xcb_get_property_value(reply); - int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t); - int i; - data->targetList = malloc((nitems+1)*sizeof(xcb_atom_t)); - - for (i = 0; i < nitems; i++) - { - xcb_atom_t atom = prop[i]; - char *pszAtomName = get_atom_name(conn, atom); - data->targetList[i] = atom; - winDebug("winClipboardFlushXEvents - SelectionNotify - target[%d] %d = %s\n", i, atom, pszAtomName); - free(pszAtomName); - } - - data->targetList[nitems] = 0; - - free(reply); - } - - return WIN_XEVENTS_NOTIFY_TARGETS; -} - -static int -winClipboardSelectionNotifyData(HWND hwnd, xcb_window_t iWindow, xcb_connection_t *conn, ClipboardConversionData *data, ClipboardAtoms *atoms) -{ - xcb_atom_t encoding; - int format; - unsigned long int nitems; - unsigned long int after; - unsigned char *value; - - unsigned char *xtpText_value; - xcb_atom_t xtpText_encoding; - int xtpText_nitems; - - BOOL fSetClipboardData = TRUE; - char *pszReturnData = NULL; - UINT codepage; - wchar_t *pwszUnicodeStr = NULL; - HGLOBAL hGlobal = NULL; - char *pszGlobalData = NULL; - - /* Retrieve the selection data and delete the property */ - xcb_get_property_cookie_t cookie = xcb_get_property(conn, - TRUE, - iWindow, - atoms->atomLocalProperty, - XCB_GET_PROPERTY_TYPE_ANY, - 0, - INT_MAX); - xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL); - if (!reply) { - ErrorF("winClipboardFlushXEvents - SelectionNotify - " - "XGetWindowProperty () failed\n"); - goto winClipboardFlushXEvents_SelectionNotify_Done; - } else { - nitems = xcb_get_property_value_length(reply); - value = xcb_get_property_value(reply); - after = reply->bytes_after; - encoding = reply->type; - format = reply->format; - // We assume format == 8 (i.e. data is a sequence of bytes). It's not - // clear how anything else should be handled. - if (format != 8) - ErrorF("SelectionNotify: format is %d, proceeding as if it was 8\n", format); - } - - { - char *pszAtomName; - winDebug("SelectionNotify - returned data %lu left %lu\n", nitems, after); - pszAtomName = get_atom_name(conn, encoding); - winDebug("Notify atom name %s\n", pszAtomName); - free(pszAtomName); - } - - /* INCR reply indicates the start of a incremental transfer */ - if (encoding == atoms->atomIncr) { - winDebug("winClipboardSelectionNotifyData: starting INCR, anticipated size %d\n", *(int *)value); - data->incrsize = 0; - data->incr = malloc(*(int *)value); - // XXX: if malloc failed, we have an error - return WIN_XEVENTS_SUCCESS; - } - else if (data->incr) { - /* If an INCR transfer is in progress ... */ - if (nitems == 0) { - winDebug("winClipboardSelectionNotifyData: ending INCR, actual size %ld\n", data->incrsize); - /* a zero-length property indicates the end of the data */ - xtpText_value = data->incr; - xtpText_encoding = encoding; - // XXX: The type of the converted selection is the type of the first - // partial property. The remaining partial properties must have the - // same type. - xtpText_nitems = data->incrsize; - } - else { - /* Otherwise, continue appending the INCR data */ - winDebug("winClipboardSelectionNotifyData: INCR, %ld bytes\n", nitems); - data->incr = realloc(data->incr, data->incrsize + nitems); - memcpy(data->incr + data->incrsize, value, nitems); - data->incrsize = data->incrsize + nitems; - return WIN_XEVENTS_SUCCESS; - } - } - else { - /* Otherwise, the data is just contained in the property */ - winDebug("winClipboardSelectionNotifyData: non-INCR, %ld bytes\n", nitems); - xtpText_value = value; - xtpText_encoding = encoding; - xtpText_nitems = nitems; - } - - if (xtpText_encoding == atoms->atomUTF8String) { - pszReturnData = malloc(xtpText_nitems + 1); - memcpy(pszReturnData, xtpText_value, xtpText_nitems); - pszReturnData[xtpText_nitems] = 0; - codepage = CP_UTF8; // code page identifier for utf8 - } else if (xtpText_encoding == XCB_ATOM_STRING) { - // STRING encoding is Latin1 (ISO8859-1) plus tab and newline - pszReturnData = malloc(xtpText_nitems + 1); - memcpy(pszReturnData, xtpText_value, xtpText_nitems); - pszReturnData[xtpText_nitems] = 0; - codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1 - } else if (xtpText_encoding == atoms->atomCompoundText) { - // COMPOUND_TEXT is complex, based on ISO 2022 - ErrorF("SelectionNotify: data in COMPOUND_TEXT encoding which is not implemented, discarding\n"); - pszReturnData = malloc(1); - pszReturnData[0] = '\0'; - } else { // shouldn't happen as we accept no other encodings - pszReturnData = malloc(1); - pszReturnData[0] = '\0'; - } - - /* Free the data returned from xcb_get_property */ - free(reply); - - /* Free any INCR data */ - if (data->incr) { - free(data->incr); - data->incr = NULL; - data->incrsize = 0; - } - - /* Convert the X clipboard string to DOS format */ - winClipboardUNIXtoDOS(&pszReturnData, strlen(pszReturnData)); - - /* Find out how much space needed when converted to UTF-16 */ - int iUnicodeLen = MultiByteToWideChar(codepage, 0, - pszReturnData, -1, NULL, 0); - - /* NOTE: iUnicodeLen includes space for null terminator */ - pwszUnicodeStr = malloc(sizeof(wchar_t) * iUnicodeLen); - if (!pwszUnicodeStr) { - ErrorF("winClipboardFlushXEvents - SelectionNotify " - "malloc failed for pwszUnicodeStr, aborting.\n"); - - /* Abort */ - goto winClipboardFlushXEvents_SelectionNotify_Done; - } - - /* Do the actual conversion */ - MultiByteToWideChar(codepage, 0, - pszReturnData, -1, pwszUnicodeStr, iUnicodeLen); - - /* Allocate global memory for the X clipboard data */ - hGlobal = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * iUnicodeLen); - - free(pszReturnData); - - /* Check that global memory was allocated */ - if (!hGlobal) { - ErrorF("winClipboardFlushXEvents - SelectionNotify " - "GlobalAlloc failed, aborting: %08x\n", (unsigned int)GetLastError()); - - /* Abort */ - 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 */ - goto winClipboardFlushXEvents_SelectionNotify_Done; - } - - /* Copy the returned string into the global memory */ - wcscpy((wchar_t *)pszGlobalData, pwszUnicodeStr); - free(pwszUnicodeStr); - pwszUnicodeStr = NULL; - - /* Release the pointer to the global memory */ - GlobalUnlock(hGlobal); - pszGlobalData = NULL; - - /* Push the selection data to the Windows clipboard */ - SetClipboardData(CF_UNICODETEXT, 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 */ - free(pwszUnicodeStr); - if (hGlobal && pszGlobalData) - GlobalUnlock(hGlobal); - if (fSetClipboardData) { - SetClipboardData(CF_UNICODETEXT, NULL); - SetClipboardData(CF_TEXT, NULL); - } - return WIN_XEVENTS_NOTIFY_DATA; -} - -/* - * Process any pending X events - */ - -int -winClipboardFlushXEvents(HWND hwnd, - xcb_window_t iWindow, xcb_connection_t *conn, - ClipboardConversionData *data, ClipboardAtoms *atoms) -{ - xcb_atom_t atomClipboard = atoms->atomClipboard; - xcb_atom_t atomUTF8String = atoms->atomUTF8String; - xcb_atom_t atomCompoundText = atoms->atomCompoundText; - xcb_atom_t atomTargets = atoms->atomTargets; - - /* Process all pending events */ - xcb_generic_event_t *event; - while ((event = xcb_poll_for_event(conn))) { - const char *pszGlobalData = NULL; - HGLOBAL hGlobal = NULL; - char *pszConvertData = NULL; - BOOL fAbort = FALSE; - BOOL fCloseClipboard = FALSE; - - /* Branch on the event type */ - switch (event->response_type & ~0x80) { - case XCB_SELECTION_REQUEST: - { - char *xtpText_value = NULL; - int xtpText_nitems; - UINT codepage; - - xcb_selection_request_event_t *selection_request = (xcb_selection_request_event_t *)event; - { - char *pszAtomName = NULL; - - winDebug("SelectionRequest - target %d\n", selection_request->target); - - pszAtomName = get_atom_name(conn, selection_request->target); - winDebug("SelectionRequest - Target atom name %s\n", pszAtomName); - free(pszAtomName); - } - - /* Abort if invalid target type */ - if (selection_request->target != XCB_ATOM_STRING - && selection_request->target != atomUTF8String - && selection_request->target != atomCompoundText - && selection_request->target != atomTargets) { - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - - /* Handle targets type of request */ - if (selection_request->target == atomTargets) { - xcb_atom_t atomTargetArr[] = - { - atomTargets, - atomUTF8String, - XCB_ATOM_STRING, - // atomCompoundText, not implemented (yet?) - }; - - /* Try to change the property */ - xcb_void_cookie_t cookie = xcb_change_property_checked(conn, - XCB_PROP_MODE_REPLACE, - selection_request->requestor, - selection_request->property, - XCB_ATOM_ATOM, - 32, - ARRAY_SIZE(atomTargetArr), - (unsigned char *) atomTargetArr); - xcb_generic_error_t *error; - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "xcb_change_property failed"); - free(error); - } - - /* Setup selection notify xevent */ - xcb_selection_notify_event_t eventSelection; - eventSelection.response_type = XCB_SELECTION_NOTIFY; - eventSelection.requestor = selection_request->requestor; - eventSelection.selection = selection_request->selection; - eventSelection.target = selection_request->target; - eventSelection.property = selection_request->property; - eventSelection.time = selection_request->time; - - /* - * Notify the requesting window that - * the operation has completed - */ - cookie = xcb_send_event_checked(conn, FALSE, - eventSelection.requestor, - 0, (char *) &eventSelection); - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "xcb_send_event() failed\n"); - } - break; - } - - /* Close clipboard if we have it open already */ - if (GetOpenClipboardWindow() == hwnd) { - CloseClipboard(); - } - - /* Access the clipboard */ - if (!OpenClipboard(hwnd)) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "OpenClipboard () failed: %08x\n", (unsigned int)GetLastError()); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - - /* Indicate that clipboard was opened */ - fCloseClipboard = TRUE; - - /* Check that clipboard format is available */ - if (!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; - } - - /* Get a pointer to the clipboard text, in desired format */ - /* Retrieve clipboard data */ - hGlobal = GetClipboardData(CF_UNICODETEXT); - - if (!hGlobal) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "GetClipboardData () failed: %08x\n", (unsigned int)GetLastError()); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - pszGlobalData = (char *) GlobalLock(hGlobal); - - /* Convert to target string style */ - if (selection_request->target == XCB_ATOM_STRING) { - codepage = CP_ISO_8559_1; // code page identifier for iso-8559-1 - } else if (selection_request->target == atomUTF8String) { - codepage = CP_UTF8; // code page identifier for utf8 - } else if (selection_request->target == atomCompoundText) { - // COMPOUND_TEXT is complex, not (yet) implemented - pszGlobalData = "COMPOUND_TEXT not implemented"; - codepage = CP_UTF8; // code page identifier for utf8 - } - - /* Convert the UTF16 string to required encoding */ - int iConvertDataLen = WideCharToMultiByte(codepage, 0, - (LPCWSTR) pszGlobalData, -1, - NULL, 0, NULL, NULL); - /* NOTE: iConvertDataLen includes space for null terminator */ - pszConvertData = malloc(iConvertDataLen); - WideCharToMultiByte(codepage, 0, - (LPCWSTR) pszGlobalData, -1, - pszConvertData, iConvertDataLen, NULL, NULL); - - /* Convert DOS string to UNIX string */ - winClipboardDOStoUNIX(pszConvertData, strlen(pszConvertData)); - - xtpText_value = strdup(pszConvertData); - xtpText_nitems = strlen(pszConvertData); - - /* data will fit into a single X request? (INCR not yet supported) */ - { - uint32_t maxreqsize = xcb_get_maximum_request_length(conn); - - /* covert to bytes and allow for allow for X_ChangeProperty request */ - maxreqsize = maxreqsize*4 - 24; - - if (xtpText_nitems > maxreqsize) { - ErrorF("winClipboardFlushXEvents - clipboard data size %d greater than maximum %u\n", xtpText_nitems, maxreqsize); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - } - - /* Copy the clipboard text to the requesting window */ - xcb_void_cookie_t cookie = xcb_change_property_checked(conn, - XCB_PROP_MODE_REPLACE, - selection_request->requestor, - selection_request->property, - selection_request->target, - 8, - xtpText_nitems, xtpText_value); - xcb_generic_error_t *error; - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "xcb_change_property failed\n"); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - - /* Free the converted string */ - free(pszConvertData); - pszConvertData = NULL; - - /* Release the clipboard data */ - GlobalUnlock(hGlobal); - pszGlobalData = NULL; - fCloseClipboard = FALSE; - CloseClipboard(); - - /* Clean up */ - free(xtpText_value); - xtpText_value = NULL; - - /* Setup selection notify event */ - xcb_selection_notify_event_t eventSelection; - eventSelection.response_type = XCB_SELECTION_NOTIFY; - eventSelection.requestor = selection_request->requestor; - eventSelection.selection = selection_request->selection; - eventSelection.target = selection_request->target; - eventSelection.property = selection_request->property; - eventSelection.time = selection_request->time; - - /* Notify the requesting window that the operation has completed */ - cookie = xcb_send_event_checked(conn, FALSE, - eventSelection.requestor, - 0, (char *) &eventSelection); - if ((error = xcb_request_check(conn, cookie))) { - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "xcb_send_event() failed\n"); - - /* Abort */ - fAbort = TRUE; - goto winClipboardFlushXEvents_SelectionRequest_Done; - } - - winClipboardFlushXEvents_SelectionRequest_Done: - /* Free allocated resources */ - if (xtpText_value) { - free(xtpText_value); - } - if (pszConvertData) - 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.response_type = XCB_SELECTION_NOTIFY; - eventSelection.requestor = selection_request->requestor; - eventSelection.selection = selection_request->selection; - eventSelection.target = selection_request->target; - eventSelection.property = XCB_NONE; - eventSelection.time = selection_request->time; - - /* Notify the requesting window that the operation is complete */ - cookie = xcb_send_event_checked(conn, FALSE, - eventSelection.requestor, - 0, (char *) &eventSelection); - if ((error = xcb_request_check(conn, cookie))) { - /* - * Should not be a problem if XSendEvent fails because - * the client may simply have exited. - */ - ErrorF("winClipboardFlushXEvents - SelectionRequest - " - "xcb_send_event() failed for abort event.\n"); - } - } - - /* Close clipboard if it was opened */ - if (fCloseClipboard) { - fCloseClipboard = FALSE; - CloseClipboard(); - } - break; - } - - case XCB_SELECTION_NOTIFY: - { - xcb_selection_notify_event_t *selection_notify = (xcb_selection_notify_event_t *)event; - winDebug("winClipboardFlushXEvents - SelectionNotify\n"); - { - char *pszAtomName; - pszAtomName = get_atom_name(conn, selection_notify->selection); - winDebug("winClipboardFlushXEvents - SelectionNotify - ATOM: %s\n", pszAtomName); - free(pszAtomName); - } - - /* - SelectionNotify with property of XCB_NONE indicates either: - - (i) Generated by the X server if no owner for the specified selection exists - (perhaps it's disappeared on us mid-transaction), or - (ii) Sent by the selection owner when the requested selection conversion could - not be performed or server errors prevented the conversion data being returned - */ - if (selection_notify->property == XCB_NONE) { - ErrorF("winClipboardFlushXEvents - SelectionNotify - " - "Conversion to format %d refused.\n", - selection_notify->target); - return WIN_XEVENTS_FAILED; - } - - if (selection_notify->target == atomTargets) { - return winClipboardSelectionNotifyTargets(hwnd, iWindow, conn, data, atoms); - } - - return winClipboardSelectionNotifyData(hwnd, iWindow, conn, data, atoms); - } - - case XCB_SELECTION_CLEAR: - winDebug("SelectionClear - doing nothing\n"); - break; - - case XCB_PROPERTY_NOTIFY: - { - xcb_property_notify_event_t *property_notify = (xcb_property_notify_event_t *)event; - - /* If INCR is in progress, collect the data */ - if (data->incr && - (property_notify->atom == atoms->atomLocalProperty) && - (property_notify->state == XCB_PROPERTY_NEW_VALUE)) - return winClipboardSelectionNotifyData(hwnd, iWindow, conn, data, atoms); - - break; - } - - case XCB_MAPPING_NOTIFY: - break; - - case 0: - /* This is just laziness rather than making sure we used _checked everywhere */ - { - xcb_generic_error_t *err = (xcb_generic_error_t *)event; - ErrorF("winClipboardFlushXEvents - Error code: %i, ID: 0x%08x, " - "Major opcode: %i, Minor opcode: %i\n", - err->error_code, err->resource_id, - err->major_code, err->minor_code); - } - break; - - default: - if ((event->response_type & ~0x80) == XCB_XFIXES_SELECTION_EVENT_SET_SELECTION_OWNER + xfixes_event_base) { - xcb_xfixes_selection_notify_event_t *e = (xcb_xfixes_selection_notify_event_t *)event; - winDebug("winClipboardFlushXEvents - XFixesSetSelectionOwnerNotify\n"); - - /* Save selection owners for monitored selections, ignore other selections */ - if ((e->selection == XCB_ATOM_PRIMARY) && fPrimarySelection) { - MonitorSelection(e, CLIP_OWN_PRIMARY); - } - else if (e->selection == atomClipboard) { - MonitorSelection(e, CLIP_OWN_CLIPBOARD); - } - else - break; - - /* Selection is being disowned */ - if (e->owner == XCB_NONE) { - winDebug("winClipboardFlushXEvents - No window, returning.\n"); - break; - } - - /* - XXX: there are all kinds of wacky edge cases we might need here: - - we own windows clipboard, but neither PRIMARY nor CLIPBOARD have an owner, so we should disown it? - - root window is taking ownership? - */ - - /* If we are the owner of the most recently owned selection, don't go all recursive :) */ - if ((lastOwnedSelectionIndex != CLIP_OWN_NONE) && - (s_iOwners[lastOwnedSelectionIndex] == iWindow)) { - winDebug("winClipboardFlushXEvents - Ownership changed to us, aborting.\n"); - break; - } - - /* Close clipboard if we have it open already (possible? correct??) */ - if (GetOpenClipboardWindow() == hwnd) { - CloseClipboard(); - } - - /* Access the Windows clipboard */ - if (!OpenClipboard(hwnd)) { - ErrorF("winClipboardFlushXEvents - OpenClipboard () failed: %08x\n", - (int) GetLastError()); - break; - } - - /* Take ownership of the Windows clipboard */ - if (!EmptyClipboard()) { - ErrorF("winClipboardFlushXEvents - EmptyClipboard () failed: %08x\n", - (int) GetLastError()); - break; - } - - /* Advertise regular text and unicode */ - SetClipboardData(CF_UNICODETEXT, NULL); - SetClipboardData(CF_TEXT, NULL); - - /* Release the clipboard */ - if (!CloseClipboard()) { - ErrorF("winClipboardFlushXEvents - CloseClipboard () failed: %08x\n", - (int) GetLastError()); - break; - } - } - /* XCB_XFIXES_SELECTION_EVENT_SELECTION_WINDOW_DESTROY */ - /* XCB_XFIXES_SELECTION_EVENT_SELECTION_CLIENT_CLOSE */ - else { - ErrorF("winClipboardFlushXEvents - unexpected event type %d\n", - event->response_type); - } - break; - } - - /* I/O errors etc. */ - { - int e = xcb_connection_has_error(conn); - if (e) { - ErrorF("winClipboardFlushXEvents - Fatal error %d on xcb connection\n", e); - break; - } - } - } - - return WIN_XEVENTS_SUCCESS; - -} diff --git a/hw/xwin/winclipboard/xwinclip.c b/hw/xwin/winclipboard/xwinclip.c deleted file mode 100644 index 4df8cd4af..000000000 --- a/hw/xwin/winclipboard/xwinclip.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - *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 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *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 <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "winclipboard.h" - -/* - * Main function - */ - -int -main (int argc, char *argv[]) -{ - int i; - char *pszDisplay = NULL; - - /* Parse command-line parameters */ - for (i = 1; i < argc; ++i) - { - /* Look for -display "display_name" or --display "display_name" */ - if (i < argc - 1 - && (!strcmp (argv[i], "-display") - || !strcmp (argv[i], "--display"))) - { - /* Grab a pointer to the display parameter */ - pszDisplay = argv[i + 1]; - - /* Skip the display argument */ - i++; - continue; - } - - /* Look for -noprimary */ - if (!strcmp (argv[i], "-noprimary")) - { - fPrimarySelection = 0; - continue; - } - - /* Yack when we find a parameter that we don't know about */ - printf ("Unknown parameter: %s\nExiting.\n", argv[i]); - exit (1); - } - - winClipboardProc(pszDisplay, NULL /* Use XAUTHORITY for auth data */); - - return 0; -} diff --git a/hw/xwin/winclipboard/xwinclip.man b/hw/xwin/winclipboard/xwinclip.man deleted file mode 100644 index f0c2fc32b..000000000 --- a/hw/xwin/winclipboard/xwinclip.man +++ /dev/null @@ -1,62 +0,0 @@ -.TH xwinclip 1 @xorgversion@ -.SH NAME -xwinclip - An X11 and Windows clipboard integration tool - -.SH SYNOPSIS -.B xwinclip [OPTION]... - -.SH DESCRIPTION -\fIxwinclip\fP is a tool for copying and pasting text between the Windows and X11 clipboard systems. - -\fIxwinclip\fP watches for updates to either clipboard and copies data between them when either one is updated. - -\fIxwinclip\fP monitors the X PRIMARY and CLIBPOARD selections for changes in ownership, and makes -the contents of the most recent one to change available to paste from the Windows clipboard. - -It also monitors the contents of the Windows clipboard for changes, taking ownership of the PRIMARY and -CLIPBOARD selections, and making the contents of the Windows clipboard available in them. - -.B Note well: -The \fIXWin(1)\fP X server has internal clipboard integration that is enabled by default. -Do \fINOT\fP run \fIxwinclip\fP unless \fIXWin(1)\fP has been started with the -noclipboard option. - -.SH OPTIONS -\fIxwinclip\fP accepts the following optional command line switches: - -.TP 8 -.B \-display [display] -Specifies the X server display to connect to. -.TP 8 -.B \-noprimary -Do not monitor the PRIMARY selection. - -.SH "SEE ALSO" -XWin(1) - -.SH BUGS -Only text clipboard contents are supported. - -The INCR (Incremental transfer) clipboard protocol for clipboard contents larger than the maximum size of an X -request (approximately 256K) is only supported for X -> Windows clipboard transfers. - -Some X clients, notably ones written in Tcl/Tk, do not re-assert ownership of the PRIMARY selection or update -its timestamp when its contents change, which currently prevents \fIxwinclip\fP from correctly noticing that -the PRIMARY selection's contents have changed. - -Windows clipboard rendering is synchronous in the WM_RENDER*FORMAT message (that is, we must have placed the -contents onto the clipboard by the time we return from processing this message), but we must wait for the X -client which owns the selection to convert the selection to our requested format. This is currently achieved -using a fixed timeout. After requesting conversion of the selection, if no events are received from the X -client which owns the selection for one second, the conversion is assumed to have failed. - -The XWin(1) server should indicate somehow (by placing an atom on the root window?) that it is running with its -internal clipboard integration enabled, and xwinclip should notice this and exit with an appropriate error. - -Probably many other bugs. - -.SH "CONFORMING TO" -ICCCM (Inter-Client Communication Conventions Manual) 2.0 - -.SH AUTHORS -Contributors to xwinclip include Benjamin Riefenstahl, Roland Cassard, Brian Genisio, Colin Harrison, -Harold L Hunt II, Matsuzaki Kensuke, Jon Turney, Chris Twiner and Jeremy Wilkins. diff --git a/hw/xwin/winclipboardinit.c b/hw/xwin/winclipboardinit.c deleted file mode 100644 index dbce0bc17..000000000 --- a/hw/xwin/winclipboardinit.c +++ /dev/null @@ -1,144 +0,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 <unistd.h> -#include <pthread.h> - -#include "win.h" -#include "winclipboard/winclipboard.h" -#include "windisplay.h" -#include "winauth.h" - -#define WIN_CLIPBOARD_RETRIES 40 -#define WIN_CLIPBOARD_DELAY 1 - -/* - * Local variables - */ - -static pthread_t g_ptClipboardProc; - -/* - * - */ -static void * -winClipboardThreadProc(void *arg) -{ - char szDisplay[512]; - xcb_auth_info_t *auth_info; - int clipboardRestarts = 0; - - while (1) - { - Bool fShutdown; - - ++clipboardRestarts; - - /* Setup the display connection string */ - /* - * 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 */ - ErrorF("winClipboardThreadProc - DISPLAY=%s\n", szDisplay); - - /* Flag that clipboard client has been launched */ - g_fClipboardStarted = TRUE; - - /* Use our generated cookie for authentication */ - auth_info = winGetXcbAuthInfo(); - - fShutdown = winClipboardProc(szDisplay, auth_info); - - /* Flag that clipboard client has stopped */ - g_fClipboardStarted = FALSE; - - if (fShutdown) - break; - - /* checking if we need to restart */ - if (clipboardRestarts >= WIN_CLIPBOARD_RETRIES) { - /* terminates clipboard thread but the main server still lives */ - ErrorF("winClipboardProc - the clipboard thread has restarted %d times and seems to be unstable, disabling clipboard integration\n", clipboardRestarts); - g_fClipboard = FALSE; - break; - } - - sleep(WIN_CLIPBOARD_DELAY); - ErrorF("winClipboardProc - trying to restart clipboard thread \n"); - } - - return NULL; -} - -/* - * Initialize the Clipboard module - */ - -Bool -winInitClipboard(void) -{ - winDebug("winInitClipboard ()\n"); - - /* Spawn a thread for the Clipboard module */ - if (pthread_create(&g_ptClipboardProc, NULL, winClipboardThreadProc, NULL)) { - /* Bail if thread creation failed */ - ErrorF("winInitClipboard - pthread_create failed.\n"); - return FALSE; - } - - return TRUE; -} - -void -winClipboardShutdown(void) -{ - /* Close down clipboard resources */ - if (g_fClipboard && g_fClipboardStarted) { - /* Synchronously destroy the clipboard window */ - winClipboardWindowDestroy(); - - /* Wait for the clipboard thread to exit */ - pthread_join(g_ptClipboardProc, NULL); - - g_fClipboardStarted = FALSE; - - winDebug("winClipboardShutdown - Clipboard thread has exited.\n"); - } -} diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c deleted file mode 100644 index 2e6b63287..000000000 --- a/hw/xwin/winclipboardwrappers.c +++ /dev/null @@ -1,139 +0,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> -#endif - -#include "win.h" -#include "dixstruct.h" - -/* - * Local function prototypes - */ - -DISPATCH_PROC(winProcEstablishConnection); - -/* - * Wrapper for internal EstablishConnection function. - * Initializes internal clients that must not be started until - * an external client has connected. - */ - -int -winProcEstablishConnection(ClientPtr client) -{ - int iReturn; - static int s_iCallCount = 0; - static unsigned long s_ulServerGeneration = 0; - - if (s_iCallCount == 0) - winDebug("winProcEstablishConnection - Hello\n"); - - /* Do nothing if clipboard is not enabled */ - if (!g_fClipboard) { - ErrorF("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; - } - - /* Watch for server reset */ - if (s_ulServerGeneration != serverGeneration) { - /* Save new generation number */ - s_ulServerGeneration = serverGeneration; - - /* 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; - } - - /* Clear original function pointer */ - winProcEstablishConnectionOrig = NULL; - - /* 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; - } - - ErrorF("winProcEstablishConnection - winInitClipboard returned.\n"); - } - - return iReturn; -} diff --git a/hw/xwin/wincmap.c b/hw/xwin/wincmap.c deleted file mode 100644 index 000334ce3..000000000 --- a/hw/xwin/wincmap.c +++ /dev/null @@ -1,602 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#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; - -#if CYGDEBUG - winDebug("winInstallColormap\n"); -#endif - - /* Did the colormap actually change? */ - if (pColormap != oldpmap) { -#if CYGDEBUG - winDebug("winInstallColormap - Colormap has changed, attempt " - "to install.\n"); -#endif - - /* 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))) { - winErrorFVerb(2, - "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; - -#if CYGDEBUG - winDebug("winUninstallColormap\n"); -#endif - - /* 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((void *) &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; - -#if CYGDEBUG - 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; - -#if CYGDEBUG - winDebug("winStoreColors - nRed %d nGreen %d nBlue %d\n", - nRed, nGreen, nBlue); -#endif - } - - /* Call the engine specific store colors procedure */ - if (!((pScreenPriv->pwinStoreColors) (pmap, ndef, pdefs))) { - winErrorFVerb(2, - "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) -{ -#if CYGDEBUG - winDebug("winResolveColor ()\n"); -#endif - - 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); - -#if CYGDEBUG - winDebug("winCreateColormap\n"); -#endif - - /* 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))) { - winErrorFVerb(2, - "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); - -#if CYGDEBUG - winDebug("winDestroyColormap - Returning\n"); -#endif -} - -/* - * 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; - } - -#if CYGDEBUG - winDebug("winGetPaletteDIB - Retrieved %d colors from DIB\n", - uiColorsRetrieved); -#endif - - /* 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; - -#if CYGDEBUG - winDebug("winGetPaletteDIB - Allocating a color: %u; " - "%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue); -#endif - - /* 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; - } - -#if CYGDEBUG - winDebug("winGetPaletteDD - uiSystemPaletteEntries %d\n", - uiSystemPaletteEntries); -#endif - - /* 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; -#if CYGDEBUG - winDebug("winGetPaletteDD - Allocating a color: %u; " - "%d %d %d\n", (unsigned int)pixel, nRed, nGreen, nBlue); -#endif - 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; - -#if CYGDEBUG - winDebug("winCreateDefColormap\n"); -#endif - - /* 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. - */ - -#if CYGDEBUG - winDebug("winCreateDefColormap - defColormap: %lu\n", pScreen->defColormap); -#endif - - /* 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; - } - -#if CYGDEBUG - winDebug("winCreateDefColormap - Created a colormap\n"); -#endif - - /* 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; - -#if 0 - /* Have to reserve first 10 and last ten pixels in DirectDraw windowed */ - if (pScreenInfo->dwEngine != WIN_SERVER_SHADOW_GDI) { - int k; - Pixel p; - - for (k = 1; k < 10; ++k) { - p = k; - if (AllocColor(pcmap, &ones, &ones, &ones, &p, 0) != Success) - FatalError("Foo!\n"); - } - - for (k = 245; k < 255; ++k) { - p = k; - if (AllocColor(pcmap, &zero, &zero, &zero, &p, 0) != Success) - FatalError("Baz!\n"); - } - } -#endif - } - - /* Install the created colormap */ - (*pScreen->InstallColormap) (pcmap); - -#if CYGDEBUG - winDebug("winCreateDefColormap - Returning\n"); -#endif - - return TRUE; -} diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c deleted file mode 100644 index 4f16b21e0..000000000 --- a/hw/xwin/winconfig.c +++ /dev/null @@ -1,1020 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Alexander Gottwald - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winconfig.h" -#include "winmsg.h" -#include "globals.h" - -#include "xkbsrv.h" - -#ifdef XWIN_XF86CONFIG -#ifndef CONFIGPATH -#define CONFIGPATH "%A," "%R," \ - "/etc/X11/%R," "%P/etc/X11/%R," \ - "%E," "%F," \ - "/etc/X11/%F," "%P/etc/X11/%F," \ - "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ - "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif -#ifndef CONFIGDIRPATH -#define CONFIGDIRPATH "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ - "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif - -XF86ConfigPtr g_xf86configptr = NULL; -#endif - -WinCmdlineRec g_cmdline = { -#ifdef XWIN_XF86CONFIG - NULL, /* configFile */ - NULL, /* configDir */ -#endif - NULL, /* fontPath */ -#ifdef XWIN_XF86CONFIG - NULL, /* keyboard */ -#endif - 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} -}; - -#define NULL_IF_EMPTY(x) (winNameCompare(x,"")?x:NULL) - -#ifdef XWIN_XF86CONFIG -serverLayoutRec g_winConfigLayout; - -static Bool ParseOptionValue(int scrnIndex, void *options, OptionInfoPtr p); -static Bool configLayout(serverLayoutPtr, XF86ConfLayoutPtr, char *); -static Bool configImpliedLayout(serverLayoutPtr, XF86ConfScreenPtr); -static Bool GetBoolValue(OptionInfoPtr p, const char *s); - -Bool -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; - } - 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); - - /* Hack for backward compatibility */ - if (!filename && from == X_DEFAULT) - filename = xf86openConfigFile(CONFIGPATH, "XF86Config", PROJECTROOT); - - if (filename) { - winMsg(from, "Using config file: \"%s\"\n", filename); - } - else { - winMsg(X_ERROR, "Unable to locate/open config file"); - if (xf86ConfigFile) - ErrorF(": \"%s\"", xf86ConfigFile); - ErrorF("\n"); - } - 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"); - } - if (!filename && !dirname) { - return FALSE; - } - free(filename); - free(dirname); - if ((g_xf86configptr = xf86readConfigFile()) == NULL) { - winMsg(X_ERROR, "Problem parsing the config file\n"); - return FALSE; - } - xf86closeConfigFile(); - - LogPrintMarkers(); - - /* set options from data structure */ - - if (g_xf86configptr->conf_layout_lst == NULL || - g_cmdline.screenname != NULL) { - if (g_cmdline.screenname == NULL) { - winMsg(X_WARNING, - "No Layout section. Using the first Screen section.\n"); - } - if (!configImpliedLayout(&g_winConfigLayout, - g_xf86configptr->conf_screen_lst)) { - winMsg(X_ERROR, "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; - void *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)) { - winMsg(X_ERROR, "Unable to determine the screen layout\n"); - return FALSE; - } - } - else { - if (!configLayout(&g_winConfigLayout, - g_xf86configptr->conf_layout_lst, NULL)) { - winMsg(X_ERROR, "Unable to determine the screen layout\n"); - return FALSE; - } - } - } - - /* setup special config files */ - winConfigFiles(); - return retval; -} -#endif - -/* load layout definitions */ -#include "winlayouts.h" - -/* Set the keyboard configuration */ -Bool -winConfigKeyboard(DeviceIntPtr pDevice) -{ - char layoutName[KL_NAMELENGTH]; - unsigned char layoutFriendlyName[256]; - unsigned int layoutNum = 0; - unsigned int deviceIdentifier = 0; - int keyboardType; - -#ifdef XWIN_XF86CONFIG - 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; - winMsg(X_PROBED, "Setting autorepeat to delay=%ld, rate=%ld\n", - g_winInfo.keyboard.delay, g_winInfo.keyboard.rate); - - } - } - - keyboardType = GetKeyboardType(0); - if (keyboardType > 0 && GetKeyboardLayoutName(layoutName)) { - WinKBLayoutPtr pLayout; - Bool bfound = FALSE; - int pass; - - layoutNum = strtoul(layoutName, (char **) NULL, 16); - if ((layoutNum & 0xffff) == 0x411) { - 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) - winMsg(X_INFO, "Loading US keyboard layout.\n"); - else - winMsg(X_ERROR, "LoadKeyboardLayout failed.\n"); - } - } - - /* 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, ®key)) - RegQueryValueEx(regkey, "Layout Text", 0, NULL, - layoutFriendlyName, &namesize); - - /* Close registry key */ - if (regkey) - RegCloseKey(regkey); - free(regpath); - } - - winMsg(X_PROBED, - "Windows keyboard layout: \"%s\" (%08x) \"%s\", type %d\n", - layoutName, layoutNum, layoutFriendlyName, keyboardType); - - deviceIdentifier = layoutNum >> 16; - for (pass = 0; pass < 2; pass++) { - /* If we didn't find an exact match for the input locale identifier, - try to find an match on the language identifier part only */ - if (pass == 1) - layoutNum = (layoutNum & 0xffff); - - for (pLayout = winKBLayouts; pLayout->winlayout != -1; pLayout++) { - if (pLayout->winlayout != layoutNum) - continue; - if (pLayout->winkbtype > 0 && pLayout->winkbtype != keyboardType) - continue; - - bfound = TRUE; - winMsg(X_PROBED, - "Found matching XKB configuration \"%s\"\n", - pLayout->layoutname); - - winMsg(X_PROBED, - "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; - - if (deviceIdentifier == 0xa000) { - winMsg(X_PROBED, "Windows keyboard layout device identifier indicates Macintosh, setting Model = \"macintosh\""); - g_winInfo.xkb.model = "macintosh"; - } - - break; - } - - if (bfound) - break; - } - - if (!bfound) { - winMsg(X_ERROR, - "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; - - /* - * 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 (kbd != NULL) { - - if (kbd->inp_identifier) - winMsg(kbdfrom, "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) { - winErrorFVerb(2, "\"%s\" is not a valid AutoRepeat value", s); - free(s); - return FALSE; - } - free(s); - winMsg(X_CONFIG, "AutoRepeat: %ld %ld\n", - g_winInfo.keyboard.delay, g_winInfo.keyboard.rate); - } -#endif - - s = NULL; - if (g_cmdline.xkbRules) { - s = g_cmdline.xkbRules; - from = X_CMDLINE; - } -#ifdef XWIN_XF86CONFIG - else { - s = winSetStrOption(kbd->inp_option_lst, "XkbRules", NULL); - from = X_CONFIG; - } -#endif - if (s) { - g_winInfo.xkb.rules = NULL_IF_EMPTY(s); - winMsg(from, "XKB: rules: \"%s\"\n", s); - } - - s = NULL; - if (g_cmdline.xkbModel) { - s = g_cmdline.xkbModel; - from = X_CMDLINE; - } -#ifdef XWIN_XF86CONFIG - else { - s = winSetStrOption(kbd->inp_option_lst, "XkbModel", NULL); - from = X_CONFIG; - } -#endif - if (s) { - g_winInfo.xkb.model = NULL_IF_EMPTY(s); - winMsg(from, "XKB: model: \"%s\"\n", s); - } - - s = NULL; - if (g_cmdline.xkbLayout) { - s = g_cmdline.xkbLayout; - from = X_CMDLINE; - } -#ifdef XWIN_XF86CONFIG - else { - s = winSetStrOption(kbd->inp_option_lst, "XkbLayout", NULL); - from = X_CONFIG; - } -#endif - if (s) { - g_winInfo.xkb.layout = NULL_IF_EMPTY(s); - winMsg(from, "XKB: layout: \"%s\"\n", s); - } - - s = NULL; - if (g_cmdline.xkbVariant) { - s = g_cmdline.xkbVariant; - from = X_CMDLINE; - } -#ifdef XWIN_XF86CONFIG - else { - s = winSetStrOption(kbd->inp_option_lst, "XkbVariant", NULL); - from = X_CONFIG; - } -#endif - if (s) { - g_winInfo.xkb.variant = NULL_IF_EMPTY(s); - winMsg(from, "XKB: variant: \"%s\"\n", s); - } - - s = NULL; - if (g_cmdline.xkbOptions) { - s = g_cmdline.xkbOptions; - from = X_CMDLINE; - } -#ifdef XWIN_XF86CONFIG - else { - s = winSetStrOption(kbd->inp_option_lst, "XkbOptions", NULL); - from = X_CONFIG; - } -#endif - if (s) { - g_winInfo.xkb.options = NULL_IF_EMPTY(s); - winMsg(from, "XKB: options: \"%s\"\n", s); - } - -#ifdef XWIN_XF86CONFIG - } -#endif - - return TRUE; -} - -#ifdef XWIN_XF86CONFIG -Bool -winConfigMouse(DeviceIntPtr pDevice) -{ - MessageType mousefrom = X_CONFIG; - - XF86ConfInputPtr mouse = NULL; - XF86ConfInputPtr input_list = NULL; - - if (g_cmdline.mouse) - mousefrom = X_CMDLINE; - - 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; - } - - if (mouse != NULL) { - if (mouse->inp_identifier) - winMsg(mousefrom, "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 { - winMsg(X_ERROR, "No primary pointer configured\n"); - winMsg(X_DEFAULT, "Using compiletime defaults for pointer\n"); - } - - return TRUE; -} - -Bool -winConfigFiles() -{ - MessageType from; - XF86ConfFilesPtr filesptr = NULL; - - /* set some shortcuts */ - if (g_xf86configptr != NULL) { - filesptr = g_xf86configptr->conf_files; - } - - /* Fontpath */ - from = X_DEFAULT; - - 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); - } - winMsg(from, "FontPath set to \"%s\"\n", defaultFontPath); - - return TRUE; -} -#else -Bool -winConfigFiles(void) -{ - /* Fontpath */ - if (g_cmdline.fontPath) { - defaultFontPath = g_cmdline.fontPath; - winMsg(X_CMDLINE, "FontPath set to \"%s\"\n", defaultFontPath); - } - - return TRUE; -} -#endif - -Bool -winConfigOptions(void) -{ - return TRUE; -} - -Bool -winConfigScreens(void) -{ - return TRUE; -} - -#ifdef XWIN_XF86CONFIG -char * -winSetStrOption(void *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; -} - -int -winSetBoolOption(void *optlist, const char *name, int deflt) -{ - OptionInfoRec o; - - o.name = name; - o.type = OPTV_BOOLEAN; - if (ParseOptionValue(-1, optlist, &o)) - deflt = o.value.boolean; - return deflt; -} - -int -winSetIntOption(void *optlist, const char *name, int deflt) -{ - OptionInfoRec o; - - o.name = name; - o.type = OPTV_INTEGER; - if (ParseOptionValue(-1, optlist, &o)) - deflt = o.value.num; - return deflt; -} - -double -winSetRealOption(void *optlist, const char *name, double deflt) -{ - OptionInfoRec o; - - o.name = name; - o.type = OPTV_REAL; - if (ParseOptionValue(-1, optlist, &o)) - deflt = o.value.realnum; - return deflt; -} - -double -winSetPercentOption(void *optlist, const char *name, double deflt) -{ - OptionInfoRec o; - - 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 - * not existing. - */ - -int -winNameCompare(const char *s1, const char *s2) -{ - char c1, c2; - - 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++; - - 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; -} - -#ifdef XWIN_XF86CONFIG -/* - * Find the named option in the list. - * @return the pointer to the option record, or NULL if not found. - */ - -XF86OptionPtr -winFindOption(XF86OptionPtr list, const char *name) -{ - while (list) { - if (winNameCompare(list->opt_name, name) == 0) - return list; - list = list->list.next; - } - 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) -{ - list = winFindOption(list, name); - if (list) { - if (list->opt_val) - return list->opt_val; - else - return ""; - } - return NULL; -} - -/* - * Parse the option. - */ - -static Bool -ParseOptionValue(int scrnIndex, void *options, OptionInfoPtr p) -{ - char *s, *end; - - if ((s = winFindOptionValue(options, p->name)) != NULL) { - switch (p->type) { - case OPTV_INTEGER: - if (*s == '\0') { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires an integer value\n", p->name); - p->found = FALSE; - } - else { - p->value.num = strtoul(s, &end, 0); - if (*end == '\0') { - p->found = TRUE; - } - else { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires an integer value\n", - p->name); - p->found = FALSE; - } - } - break; - case OPTV_STRING: - if (*s == '\0') { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a 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') { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a floating point value\n", - p->name); - p->found = FALSE; - } - else { - p->value.realnum = strtod(s, &end); - if (*end == '\0') { - p->found = TRUE; - } - else { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a floating point value\n", - p->name); - p->found = FALSE; - } - } - break; - case OPTV_BOOLEAN: - if (GetBoolValue(p, s)) { - p->found = TRUE; - } - else { - winDrvMsg(scrnIndex, X_WARNING, - "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') { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a frequency value\n", - p->name); - p->found = FALSE; - } - else { - double freq = strtod(s, &end); - int units = 0; - - if (end != s) { - p->found = TRUE; - if (!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 { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a frequency value\n", - p->name); - p->found = FALSE; - } - if (p->found) - freq *= (double) units; - } - else { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a frequency value\n", - p->name); - p->found = FALSE; - } - if (p->found) { - p->value.freq.freq = freq; - p->value.freq.units = units; - } - } - break; - case OPTV_NONE: - /* Should never get here */ - p->found = FALSE; - break; - } - if (p->found) { - winDrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", p->name); - if (!(p->type == OPTV_BOOLEAN && *s == 0)) { - winErrorFVerb(2, " \"%s\"", s); - } - winErrorFVerb(2, "\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.boolean = !opt.value.boolean; - p->found = TRUE; - } - else { - winDrvMsg(scrnIndex, X_WARNING, - "Option \"%s\" requires a boolean value\n", newn); - p->found = FALSE; - } - } - else { - p->found = FALSE; - } - if (p->found) { - winDrvMsgVerb(scrnIndex, X_CONFIG, 2, "Option \"%s\"", newn); - if (*s != 0) { - winErrorFVerb(2, " \"%s\"", s); - } - winErrorFVerb(2, "\n"); - } - free(n); - } - else { - p->found = FALSE; - } - return p->found; -} - -static Bool -configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout, - char *default_layout) -{ -#if 0 -#pragma warn UNIMPLEMENTED -#endif - return TRUE; -} - -static Bool -configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen) -{ -#if 0 -#pragma warn UNIMPLEMENTED -#endif - return TRUE; -} - -static Bool -GetBoolValue(OptionInfoPtr p, const char *s) -{ - if (*s == 0) { - p->value.boolean = TRUE; - } - else { - if (winNameCompare(s, "1") == 0) - p->value.boolean = TRUE; - else if (winNameCompare(s, "on") == 0) - p->value.boolean = TRUE; - else if (winNameCompare(s, "true") == 0) - p->value.boolean = TRUE; - else if (winNameCompare(s, "yes") == 0) - p->value.boolean = TRUE; - else if (winNameCompare(s, "0") == 0) - p->value.boolean = FALSE; - else if (winNameCompare(s, "off") == 0) - p->value.boolean = FALSE; - else if (winNameCompare(s, "false") == 0) - p->value.boolean = FALSE; - else if (winNameCompare(s, "no") == 0) - p->value.boolean = FALSE; - } - return TRUE; -} -#endif - -char * -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; - } - } - *q = '\0'; - return ret; -} diff --git a/hw/xwin/winconfig.h b/hw/xwin/winconfig.h deleted file mode 100644 index bd1f59650..000000000 --- a/hw/xwin/winconfig.h +++ /dev/null @@ -1,263 +0,0 @@ -#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; - void *options; - int screen; /* For multi-CRTC cards */ -} GDevRec, *GDevPtr; - -typedef struct { - char *identifier; - char *driver; - void *commonOptions; - void *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; - void *options; -} DispRec, *DispPtr; - -typedef struct _confxvportrec { - char *identifier; - void *options; -} confXvPortRec, *confXvPortPtr; - -typedef struct _confxvadaptrec { - char *identifier; - int numports; - confXvPortPtr ports; - void *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; - void *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; - void *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 boolean; - 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(void *optlist, const char *name, char *deflt); -int winSetBoolOption(void *optlist, const char *name, int deflt); -int winSetIntOption(void *optlist, const char *name, int deflt); -double winSetRealOption(void *optlist, const char *name, double deflt); -double winSetPercentOption(void *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/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c deleted file mode 100644 index 444e843ec..000000000 --- a/hw/xwin/wincreatewnd.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - *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 "shellapi.h" - -/* - * Local function prototypes - */ - -static Bool - winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo); - -static Bool - winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo); - -/* - * Create a full screen window - */ - -Bool -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]; - -#if CYGDEBUG - winDebug("winCreateBoundingWindowFullScreen\n"); -#endif - - /* 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 = pScreenInfo->hIcon; - wc.hCursor = 0; - wc.hbrBackground = 0; - wc.lpszMenuName = NULL; - wc.lpszClassName = WINDOW_CLASS; - wc.hIconSm = pScreenInfo->hIconSm; - RegisterClassEx(&wc); - - /* Set display and screen-specific tooltip text */ - if (g_pszQueryHost != NULL) - snprintf(szTitle, - sizeof(szTitle), - WINDOW_TITLE_XDMCP, - g_pszQueryHost, display, (int) pScreenInfo->dwScreen); - else - snprintf(szTitle, - sizeof(szTitle), - WINDOW_TITLE, 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 */ - - /* Hide the window */ - ShowWindow(*phwnd, SW_SHOWNORMAL); - - /* Send first paint message */ - UpdateWindow(*phwnd); - - /* Attempt to bring our window to the top of the display */ - BringWindowToTop(*phwnd); - - return TRUE; -} - -/* - * Create our primary Windows display window - */ - -Bool -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]; - - 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 - && !pScreenInfo->fRootless - && !pScreenInfo->fMultiWindow - ) { - /* 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; - - GetStartupInfo(&startupInfo); - if (startupInfo.dwFlags & STARTF_USESHOWWINDOW && - startupInfo.wShowWindow == SW_HIDE) { - fForceShowWindow = TRUE; - } - dwWindowStyle |= WS_CAPTION; - if (pScreenInfo->iResizeMode != resizeNotAllowed) - 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 = pScreenInfo->hIcon; - wc.hCursor = 0; - wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = WINDOW_CLASS; - wc.hIconSm = pScreenInfo->hIconSm; - 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; - } - - /* Clean up the scrollbars flag, if necessary */ - if ((!pScreenInfo->fDecoration - || pScreenInfo->fRootless - || pScreenInfo->fMultiWindow - ) - && (pScreenInfo->iResizeMode == resizeWithScrollbars)) { - /* We cannot have scrollbars if we do not have a window border */ - pScreenInfo->iResizeMode = resizeNotAllowed; - } - - /* Did the user specify a height and width? */ - if (pScreenInfo->fUserGaveHeightAndWidth) { - /* User gave a desired height and width, try to accommodate */ -#if CYGDEBUG - winDebug("winCreateBoundingWindowWindowed - User gave height " - "and width\n"); -#endif - - /* Adjust the window width and height for borders and title bar */ - if (pScreenInfo->fDecoration - && !pScreenInfo->fRootless - && !pScreenInfo->fMultiWindow - ) { -#if CYGDEBUG - winDebug - ("winCreateBoundingWindowWindowed - Window has decoration\n"); -#endif - - /* Are we resizable */ - if (pScreenInfo->iResizeMode != resizeNotAllowed) { -#if CYGDEBUG - winDebug - ("winCreateBoundingWindowWindowed - Window is resizable\n"); -#endif - - iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME); - iHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME) - + GetSystemMetrics(SM_CYCAPTION); - } - else { -#if CYGDEBUG - winDebug - ("winCreateBoundingWindowWindowed - Window is not resizable\n"); -#endif - - 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 */ -#if CYGDEBUG - winDebug("winCreateBoundingWindowWindowed - User did not give " - "height and width\n"); -#endif - /* 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 - && !pScreenInfo->fMultiWindow - ) { - /* 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; - -#if CYGDEBUG - winDebug("winCreateBoundingWindowWindowed - Adjusted width: %d " - "height: %d\n", iWidth, iHeight); -#endif - } - - /* Set display and screen-specific tooltip text */ - if (g_pszQueryHost != NULL) - snprintf(szTitle, - sizeof(szTitle), - WINDOW_TITLE_XDMCP, - g_pszQueryHost, display, (int) pScreenInfo->dwScreen); - else - snprintf(szTitle, - sizeof(szTitle), - WINDOW_TITLE, 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; - } - -#if CYGDEBUG - winDebug("winCreateBoundingWindowWindowed - CreateWindowEx () returned\n"); -#endif - - 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; - } - - winDebug("winCreateBoundingWindowWindowed - WindowClient " - "w %d h %d r %d l %d b %d t %d\n", - (int)(rcClient.right - rcClient.left), - (int)(rcClient.bottom - rcClient.top), - (int)rcClient.right, (int)rcClient.left, - (int)rcClient.bottom, (int)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); - } -#endif - - /* Show the window */ - if (FALSE - || pScreenInfo->fMultiWindow - ) { - pScreenPriv->fRootWindowShown = FALSE; - ShowWindow(*phwnd, SW_HIDE); - } - 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 - && !pScreenInfo->fRootless - && !pScreenInfo->fMultiWindow - ) { - if (!BringWindowToTop(*phwnd)) { - ErrorF("winCreateBoundingWindowWindowed - BringWindowToTop () " - "failed\n"); - return FALSE; - } - } - - winDebug("winCreateBoundingWindowWindowed - Returning\n"); - - return TRUE; -} - -/* - * Find the work area of all attached monitors - */ - -static Bool -winGetWorkArea(RECT * prcWorkArea, winScreenInfo * pScreenInfo) -{ - int iPrimaryWidth, iPrimaryHeight; - int iWidth, iHeight; - int iLeft, iTop; - int iPrimaryNonWorkAreaWidth, iPrimaryNonWorkAreaHeight; - - /* Use GetMonitorInfo to get work area for monitor */ - if (!pScreenInfo->fMultipleMonitors) { - MONITORINFO mi; - - mi.cbSize = sizeof(MONITORINFO); - if (GetMonitorInfo(pScreenInfo->hMonitor, &mi)) { - *prcWorkArea = mi.rcWork; - - winDebug("winGetWorkArea - Monitor %d WorkArea: %d %d %d %d\n", - pScreenInfo->iMonitor, - (int) prcWorkArea->top, (int) prcWorkArea->left, - (int) prcWorkArea->bottom, (int) prcWorkArea->right); - } - else { - ErrorF("winGetWorkArea - GetMonitorInfo() failed for monitor %d\n", - pScreenInfo->iMonitor); - } - - /* 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); - - /* 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); - - /* 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 - 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; - } - 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 -winTaskbarOnScreenEdge(unsigned int uEdge, winScreenInfo * pScreenInfo) -{ - APPBARDATA abd; - HWND hwndAutoHide; - - ZeroMemory(&abd, sizeof(abd)); - abd.cbSize = sizeof(abd); - abd.uEdge = uEdge; - - hwndAutoHide = (HWND) SHAppBarMessage(ABM_GETAUTOHIDEBAR, &abd); - if (hwndAutoHide != NULL) { - /* - Found an autohide taskbar on that edge, but is it on the - same monitor as the screen window? - */ - if (pScreenInfo->fMultipleMonitors || - (MonitorFromWindow(hwndAutoHide, MONITOR_DEFAULTTONULL) == - pScreenInfo->hMonitor)) - return TRUE; - } - return FALSE; -} - -/* - * Adjust the client area so that any auto-hide toolbars - * will work correctly. - */ - -static Bool -winAdjustForAutoHide(RECT * prcWorkArea, winScreenInfo * pScreenInfo) -{ - APPBARDATA abd; - - 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"); - - /* - 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 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 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); - - return TRUE; -} diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c deleted file mode 100644 index 3fc050bfa..000000000 --- a/hw/xwin/wincursor.c +++ /dev/null @@ -1,611 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#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) - -#if 0 -#define WIN_DEBUG_MSG winDebug -#else -#define WIN_DEBUG_MSG(...) -#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; - - winErrorFVerb(2, - "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 - || pScreenPriv->pScreenInfo->fMultiWindow - ) { - /* 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; - unsigned char bit; - HDC hDC; - BITMAPV4HEADER bi; - BITMAPINFO *pbmi; - uint32_t *lpBits; - - WIN_DEBUG_MSG("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 whether the X11 cursor is bigger than the win32 cursor */ - if (pScreenPriv->cursor.sm_cx < pCursor->bits->width || - pScreenPriv->cursor.sm_cy < pCursor->bits->height) { - winErrorFVerb(3, - "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) { - WIN_DEBUG_MSG("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 = calloc(pScreenPriv->cursor.sm_cx * pScreenPriv->cursor.sm_cy, - sizeof(uint32_t)); - - if (lpBits) { - int y; - for (y = 0; y < nCY; y++) { - void *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) { - RGBQUAD *pbmiColors; - /* Bicolor, use a palettized DIB */ - WIN_DEBUG_MSG("winLoadCursor: Trying two color cursor\n"); - pbmi = (BITMAPINFO *) &bi; - pbmiColors = &(pbmi->bmiColors[0]); - - 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; - - pbmiColors[0].rgbRed = 0; /* Empty */ - pbmiColors[0].rgbGreen = 0; - pbmiColors[0].rgbBlue = 0; - pbmiColors[0].rgbReserved = 0; - pbmiColors[1].rgbRed = pCursor->backRed >> 8; /* Background */ - pbmiColors[1].rgbGreen = pCursor->backGreen >> 8; - pbmiColors[1].rgbBlue = pCursor->backBlue >> 8; - pbmiColors[1].rgbReserved = 0; - pbmiColors[2].rgbRed = pCursor->foreRed >> 8; /* Foreground */ - pbmiColors[2].rgbGreen = pCursor->foreGreen >> 8; - pbmiColors[2].rgbBlue = pCursor->foreBlue >> 8; - pbmiColors[2].rgbReserved = 0; - - lpBits = calloc(pScreenPriv->cursor.sm_cx * pScreenPriv->cursor.sm_cy, 1); - - pCur = (unsigned char *) lpBits; - if (lpBits) { - int x, y; - 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) { - WIN_DEBUG_MSG("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(2, "winLoadCursor - CreateIconIndirect failed:"); - else { - if (GetIconInfo(hCursor, &ii)) { - if (ii.fIcon) { - WIN_DEBUG_MSG - ("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(2, - "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(2, "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); - WIN_DEBUG_MSG("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); - WIN_DEBUG_MSG("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); - - 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/hw/xwin/windialogs.c b/hw/xwin/windialogs.c deleted file mode 100644 index 26b2ebd2c..000000000 --- a/hw/xwin/windialogs.c +++ /dev/null @@ -1,631 +0,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 - * Earle F. Philhower III - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include <shellapi.h> -#include "winprefs.h" - -/* - * Local function prototypes - */ - -static INT_PTR CALLBACK -winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); - -static INT_PTR CALLBACK -winChangeDepthDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); - -static INT_PTR CALLBACK -winAboutDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); - -static void - winDrawURLWindow(LPARAM lParam); - -static LRESULT CALLBACK -winURLWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -static void - winOverrideURLButton(HWND hdlg, int id); - -static void - winUnoverrideURLButton(HWND hdlg, int id); - -/* - * Owner-draw a button as a URL - */ - -static void -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; - } - /* 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 - */ - -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; -} - -/* - * Register and unregister the custom WndProc - */ - -static void -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); -} - -static void -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); -} - -/* - * Center a dialog window in the desktop window - * and set small and large icons to X icons. - */ - -static void -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. */ - SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | 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); - } - - if (g_hIconX) - hIcon = g_hIconX; - else - hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_XWIN)); - - if (g_hSmallIconX) - hIconSmall = g_hSmallIconX; - else - 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); -} - -/* - * Display the Exit dialog box - */ - -void -winDisplayExitDialog(winPrivScreenPtr pScreenPriv) -{ - 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 down server internal clients */ - if (pScreenPriv->pScreenInfo->fMultiWindow) - liveClients -= 2; /* multiwindow window manager & XMsgProc */ - if (g_fClipboardStarted) - liveClients--; /* clipboard manager */ - - /* A user reported that this sometimes drops below zero. just eye-candy. */ - if (liveClients < 0) - liveClients = 0; - - /* 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; - } - - pScreenPriv->iConnectedClients = liveClients; - - /* 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); - - return; - } - - /* Create dialog box */ - g_hDlgExit = CreateDialogParam(g_hInstance, - "EXIT_DIALOG", - pScreenPriv->hwndScreen, - winExitDlgProc, (LPARAM) 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 INT_PTR CALLBACK -winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam) -{ - static winPrivScreenPtr s_pScreenPriv = NULL; - - /* 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; - - 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; - - 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; - - case WM_CLOSE: - 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; - } - - return FALSE; -} - -/* - * Display the Depth Change dialog box - */ - -void -winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv) -{ - /* 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); - - 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, - (LPARAM) pScreenPriv); - /* Show the dialog box */ - ShowWindow(g_hDlgDepthChange, SW_SHOW); - - if (!g_hDlgDepthChange) - ErrorF("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 INT_PTR CALLBACK -winChangeDepthDlgProc(HWND hwndDialog, UINT message, - WPARAM wParam, LPARAM lParam) -{ - static winPrivScreenPtr s_pScreenPriv = NULL; - static winScreenInfo *s_pScreenInfo = NULL; - -#if CYGDEBUG - winDebug("winChangeDepthDlgProc\n"); -#endif - - /* Branch on message type */ - switch (message) { - case WM_INITDIALOG: -#if CYGDEBUG - winDebug("winChangeDepthDlgProc - WM_INITDIALOG\n"); -#endif - - /* Store pointers to private structures for future use */ - s_pScreenPriv = (winPrivScreenPtr) lParam; - s_pScreenInfo = s_pScreenPriv->pScreenInfo; - -#if CYGDEBUG - winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %p, " - "s_pScreenInfo: %p\n", - s_pScreenPriv, s_pScreenInfo); -#endif - -#if CYGDEBUG - winDebug("winChangeDepthDlgProc - WM_INITDIALOG - orig bpp: %u, " - "current bpp: %d\n", - (unsigned int)s_pScreenInfo->dwBPP, - GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)); -#endif - - winInitDialog(hwndDialog); - - return TRUE; - - case WM_DISPLAYCHANGE: -#if CYGDEBUG - winDebug("winChangeDepthDlgProc - WM_DISPLAYCHANGE - orig bpp: %u, " - "new bpp: %d\n", - (unsigned int)s_pScreenInfo->dwBPP, - GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)); -#endif - - /* Dismiss the dialog if the display returns to the original depth */ - if (GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL) == - s_pScreenInfo->dwBPP) { - ErrorF("winChangeDelthDlgProc - wParam == s_pScreenInfo->dwBPP\n"); - - /* 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; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - winDebug("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"); - - 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; - } - - return FALSE; -} - -/* - * Display the About dialog box - */ - -void -winDisplayAboutDialog(winPrivScreenPtr pScreenPriv) -{ - /* 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); - - return; - } - - /* - * Display the about box - */ - g_hDlgAbout = CreateDialogParam(g_hInstance, - "ABOUT_BOX", - pScreenPriv->hwndScreen, - winAboutDlgProc, (LPARAM) 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 INT_PTR CALLBACK -winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) -{ - static winPrivScreenPtr s_pScreenPriv = NULL; - -#if CYGDEBUG - winDebug("winAboutDlgProc\n"); -#endif - - /* Branch on message type */ - switch (message) { - case WM_INITDIALOG: -#if CYGDEBUG - winDebug("winAboutDlgProc - WM_INITDIALOG\n"); -#endif - - /* Store pointer to private structure for future use */ - s_pScreenPriv = (winPrivScreenPtr) lParam; - - winInitDialog(hwndDialog); - - /* Override the URL buttons */ - winOverrideURLButton(hwndDialog, ID_ABOUT_WEBSITE); - - return TRUE; - - case WM_DRAWITEM: - /* 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; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - case IDCANCEL: - winDebug("winAboutDlgProc - WM_COMMAND - IDOK or IDCANCEL\n"); - - DestroyWindow(g_hDlgAbout); - g_hDlgAbout = NULL; - - /* 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_WEBSITE); - - return TRUE; - - case ID_ABOUT_WEBSITE: - { - const char *pszPath = __VENDORDWEBSUPPORT__; - INT_PTR iReturn; - - iReturn = (INT_PTR) ShellExecute(NULL, - "open", - pszPath, NULL, NULL, SW_MAXIMIZE); - if (iReturn < 32) { - ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - " - "ShellExecute failed: %d\n", (int)iReturn); - - } - } - return TRUE; - } - break; - - case WM_CLOSE: - winDebug("winAboutDlgProc - WM_CLOSE\n"); - - DestroyWindow(g_hDlgAbout); - g_hDlgAbout = NULL; - - /* 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_WEBSITE); - - return TRUE; - } - - return FALSE; -} diff --git a/hw/xwin/windisplay.c b/hw/xwin/windisplay.c deleted file mode 100644 index 17f0c7789..000000000 --- a/hw/xwin/windisplay.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * File: windisplay.c - * Purpose: Retrieve server display name - * - * 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 (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <opaque.h> // for display -#include "windisplay.h" -#include "winmsg.h" - -#define XSERV_t -#define TRANS_SERVER -#include <X11/Xtrans/Xtrans.h> - -/* - Generate a display name string referring to the display of this server, - using a transport we know is enabled -*/ - -void -winGetDisplayName(char *szDisplay, unsigned int screen) -{ - if (_XSERVTransIsListening("local")) { - snprintf(szDisplay, 512, ":%s.%d", display, screen); - } - else if (_XSERVTransIsListening("inet")) { - snprintf(szDisplay, 512, "127.0.0.1:%s.%d", display, screen); - } - else if (_XSERVTransIsListening("inet6")) { - snprintf(szDisplay, 512, "::1:%s.%d", display, screen); - } - else { - // this can't happen! - ErrorF("winGetDisplay: Don't know what to use for DISPLAY\n"); - snprintf(szDisplay, 512, "localhost:%s.%d", display, screen); - } - - winDebug("winGetDisplay: DISPLAY=%s\n", szDisplay); -} diff --git a/hw/xwin/windisplay.h b/hw/xwin/windisplay.h deleted file mode 100644 index d1d4549bf..000000000 --- a/hw/xwin/windisplay.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * File: windisplay.h - * Purpose: Interface to retrieve server display name - * - * 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 (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -#ifndef WINDISPLAY_H -#define WINDISPLAY_H - -void -winGetDisplayName(char *szDisplay, unsigned int screen); - -#endif /* !WINDISPLAY_H */ diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c deleted file mode 100644 index f82232424..000000000 --- a/hw/xwin/winengine.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - *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) -{ - /* Initialize the engine support flags */ - g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI; - - /* 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; - } - - /* 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, allowing ShadowDDNL\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 - || pScreenInfo->fMultiWindow - ) { - 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_DDNL: - winSetEngineFunctionsShadowDDNL(pScreen); - break; - 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; - } - - /* 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 FALSE; -} - -/* - * 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/hw/xwin/winerror.c b/hw/xwin/winerror.c deleted file mode 100644 index 784772f5f..000000000 --- a/hw/xwin/winerror.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - *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 <../xfree86/common/xorgVersion.h> -#include "win.h" - -#ifdef DDXOSVERRORF -void -OsVendorVErrorF(const char *pszFormat, va_list va_args) -{ - /* 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); - - /* Print the error message to a log file, could be stderr */ - LogVWrite(0, pszFormat, va_args); - - /* Unlock the printing mutex */ - pthread_mutex_unlock(&s_pmPrinting); -} -#endif - -/* - * os/log.c:FatalError () calls our vendor ErrorF, so the message - * from a FatalError will be logged. - * - * Attempt to do last-ditch, safe, important cleanup here. - */ -void -OsVendorFatalError(const char *f, va_list args) -{ - char errormsg[1024] = ""; - - /* Don't give duplicate warning if UseMsg was called */ - if (g_fSilentFatalError) - return; - - if (!g_fLogInited) { - g_fLogInited = TRUE; - g_pszLogFile = LogInit(g_pszLogFile, ".old"); - } - LogClose(EXIT_ERR_ABORT); - - /* Format the error message */ - vsnprintf(errormsg, sizeof(errormsg), f, args); - - /* - Sometimes the error message needs a bit of cosmetic cleaning - up for use in a dialog box... - */ - { - char *s; - - while ((s = strstr(errormsg, "\n\t")) != NULL) { - s[0] = ' '; - s[1] = '\n'; - } - } - - winMessageBoxF("A fatal error has occurred and " PROJECT_NAME " will now exit.\n\n" - "%s\n\n" - "Please open %s for more information.\n", - MB_ICONERROR, - errormsg, - (g_pszLogFile ? g_pszLogFile : "the logfile")); -} - -/* - * winMessageBoxF - Print a formatted error message in a useful - * message box. - */ - -void -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; - } - -#define MESSAGEBOXF \ - "%s\n" \ - "Vendor: %s\n" \ - "Release: %d.%d.%d.%d\n" \ - "Contact: %s\n" \ - "%s\n\n" \ - "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, - XORG_VERSION_SNAP, - BUILDERADDR, BUILDERSTRING, g_pszCommandLine); - - if (size == -1) { - pszMsgBox = NULL; - goto winMessageBoxF_Cleanup; - } - - /* Display the message box string */ - MessageBox(NULL, pszMsgBox, PROJECT_NAME, MB_OK | uType); - - winMessageBoxF_Cleanup: - free(pszErrorF); - free(pszMsgBox); -#undef MESSAGEBOXF -} diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c deleted file mode 100644 index 29abe1970..000000000 --- a/hw/xwin/winglobals.c +++ /dev/null @@ -1,105 +0,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 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 - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -/* - * General global variables - */ - -int g_iNumScreens = 0; -winScreenInfo *g_ScreenInfo = 0; - -#ifdef HAS_DEVWINDOWS -int g_fdMessageQueue = WIN_FD_INVALID; -#endif -DevPrivateKeyRec g_iScreenPrivateKeyRec; -DevPrivateKeyRec g_iCmapPrivateKeyRec; -DevPrivateKeyRec g_iGCPrivateKeyRec; -DevPrivateKeyRec g_iPixmapPrivateKeyRec; -DevPrivateKeyRec g_iWindowPrivateKeyRec; -unsigned long g_ulServerGeneration = 0; -DWORD g_dwEnginesSupported = 0; -HINSTANCE g_hInstance = 0; -HWND g_hDlgDepthChange = NULL; -HWND g_hDlgExit = NULL; -HWND g_hDlgAbout = NULL; -const char *g_pszQueryHost = NULL; -Bool g_fXdmcpEnabled = FALSE; -Bool g_fAuthEnabled = FALSE; -Bool g_fCompositeAlpha = FALSE; -HICON g_hIconX = NULL; -HICON g_hSmallIconX = NULL; - -#ifndef RELOCATE_PROJECTROOT -const char *g_pszLogFile = DEFAULT_LOGDIR "/XWin.%s.log"; -#else -const char *g_pszLogFile = "XWin.log"; -Bool g_fLogFileChanged = FALSE; -#endif -int g_iLogVerbose = 2; -Bool g_fLogInited = FALSE; -char *g_pszCommandLine = NULL; -Bool g_fSilentFatalError = FALSE; -DWORD g_dwCurrentThreadID = 0; -Bool g_fKeyboardHookLL = FALSE; -Bool g_fNoHelpMessageBox = FALSE; -Bool g_fSoftwareCursor = FALSE; -Bool g_fNativeGl = TRUE; -Bool g_fHostInTitle = TRUE; -pthread_mutex_t g_pmTerminating = PTHREAD_MUTEX_INITIALIZER; - -/* - * Wrapped DIX functions - */ -winDispatchProcPtr winProcEstablishConnectionOrig = NULL; - -/* - * Clipboard variables - */ - -Bool g_fClipboard = TRUE; -Bool g_fClipboardStarted = FALSE; - -/* - * Re-initialize global variables that are invalidated - * by a server reset. - */ - -void -winInitializeGlobals(void) -{ - g_dwCurrentThreadID = GetCurrentThreadId(); -} diff --git a/hw/xwin/winglobals.h b/hw/xwin/winglobals.h deleted file mode 100644 index 29535f05a..000000000 --- a/hw/xwin/winglobals.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - File: winglobals.h - Purpose: declarations for global variables - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice (including the next - paragraph) shall be included in all copies or substantial portions of the - Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. - -*/ - -#ifndef WINGLOBALS_H -#define WINGLOBALS_H - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include <pthread.h> - -/* - * References to external symbols - */ - -extern int g_iNumScreens; -extern int g_iLastScreen; -extern char *g_pszCommandLine; -extern Bool g_fSilentFatalError; -extern const char *g_pszLogFile; - -#ifdef RELOCATE_PROJECTROOT -extern Bool g_fLogFileChanged; -#endif -extern int g_iLogVerbose; -extern Bool g_fLogInited; - -extern Bool g_fAuthEnabled; -extern Bool g_fXdmcpEnabled; -extern Bool g_fCompositeAlpha; - -extern Bool g_fNoHelpMessageBox; -extern Bool g_fNativeGl; -extern Bool g_fHostInTitle; - -extern HWND g_hDlgDepthChange; -extern HWND g_hDlgExit; -extern HWND g_hDlgAbout; - -extern Bool g_fSoftwareCursor; -extern Bool g_fCursor; - -/* Typedef for DIX wrapper functions */ -typedef int (*winDispatchProcPtr) (ClientPtr); - -/* - * Wrapped DIX functions - */ -extern winDispatchProcPtr winProcEstablishConnectionOrig; -extern Bool g_fClipboard; -extern Bool g_fClipboardStarted; - -/* The global X default icons */ -extern HICON g_hIconX; -extern HICON g_hSmallIconX; - -extern DWORD g_dwCurrentThreadID; - -extern Bool g_fKeyboardHookLL; -extern Bool g_fButton[3]; - -extern pthread_mutex_t g_pmTerminating; - -#endif /* WINGLOBALS_H */ diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c deleted file mode 100644 index 00586c25b..000000000 --- a/hw/xwin/winkeybd.c +++ /dev/null @@ -1,545 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winkeybd.h" -#include "winconfig.h" -#include "winmsg.h" - -#include "xkbsrv.h" - -/* C does not have a logical XOR operator, so we use a macro instead */ -#define LOGICAL_XOR(a,b) ((!(a) && (b)) || ((a) && !(b))) - -static Bool g_winKeyState[NUM_KEYCODES]; - -/* - * Local prototypes - */ - -static void - winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, void *pCtrl, int iClass); - -static void - winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl); - -/* - * Translate a Windows WM_[SYS]KEY(UP/DOWN) message - * into an ASCII scan code. - * - * We do this ourselves, rather than letting Windows handle it, - * because Windows tends to munge the handling of special keys, - * like AltGr on European keyboards. - */ - -int -winTranslateKey(WPARAM wParam, LPARAM lParam) -{ - 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 iScanCode; - - winDebug("winTranslateKey: wParam %08x lParam %08x\n", (int)wParam, (int)lParam); - -/* WM_ key messages faked by Vista speech recognition (WSR) don't have a - * scan code. - * - * Vocola 3 (Rick Mohr's supplement to WSR) uses - * System.Windows.Forms.SendKeys.SendWait(), which appears always to give a - * scan code of 1 - */ - if (iParamScanCode <= 1) { - if (VK_PRIOR <= wParam && wParam <= VK_DOWN) - /* Trigger special case table to translate to extended - * keycode, otherwise if num_lock is on, we can get keypad - * numbers instead of navigation keys. */ - iParam |= KF_EXTENDED; - else - iParamScanCode = MapVirtualKeyEx(wParam, - /*MAPVK_VK_TO_VSC */ 0, - GetKeyboardLayout(0)); - } - - /* Branch on special extended, special non-extended, or normal key */ - if ((iParam & KF_EXTENDED) && iKeyFixupEx) - iScanCode = iKeyFixupEx; - else if (iKeyFixup) - iScanCode = iKeyFixup; - else if (wParam == 0 && iParamScanCode == 0x70) - iScanCode = KEY_HKTG; - else - switch (iParamScanCode) { - case 0x70: - iScanCode = KEY_HKTG; - break; - case 0x73: - iScanCode = KEY_BSlash2; - break; - default: - iScanCode = iParamScanCode; - break; - } - - return iScanCode; -} - -/* Ring the keyboard bell (system speaker on PCs) */ -static void -winKeybdBell(int iPercent, DeviceIntPtr pDeviceInt, void *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. - */ - if (iPercent > 0) MessageBeep(MB_OK); -} - -/* Change some keyboard configuration parameters */ -static void -winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl) -{ -} - -/* - * See Porting Layer Definition - p. 18 - * winKeybdProc is known as a DeviceProc. - */ - -int -winKeybdProc(DeviceIntPtr pDeviceInt, int iState) -{ - DevicePtr pDevice = (DevicePtr) pDeviceInt; - XkbSrvInfoPtr xkbi; - XkbControlsPtr ctrl; - - switch (iState) { - case DEVICE_INIT: - winConfigKeyboard(pDeviceInt); - - /* FIXME: Maybe we should use winGetKbdLeds () here? */ - defaultKeyboardControl.leds = g_winInfo.keyboard.leds; - - winErrorFVerb(2, "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 { - winErrorFVerb(1, - "winKeybdProc - Error initializing keyboard AutoRepeat\n"); - } - - break; - - case DEVICE_ON: - pDevice->on = TRUE; - - // immediately copy the state of this keyboard device to the VCK - // (which otherwise happens lazily after the first keypress) - CopyKeyClass(pDeviceInt, inputInfo.keyboard); - break; - - case DEVICE_CLOSE: - case DEVICE_OFF: - pDevice->on = FALSE; - break; - } - - return Success; -} - -/* - * Detect current mode key states upon server startup. - * - * Simulate a press and release of any key that is currently - * toggled. - */ - -void -winInitializeModeKeyStates(void) -{ - /* Restore NumLock */ - if (GetKeyState(VK_NUMLOCK) & 0x0001) { - winSendKeyEvent(KEY_NumLock, TRUE); - winSendKeyEvent(KEY_NumLock, FALSE); - } - - /* Restore CapsLock */ - if (GetKeyState(VK_CAPITAL) & 0x0001) { - winSendKeyEvent(KEY_CapsLock, TRUE); - winSendKeyEvent(KEY_CapsLock, FALSE); - } - - /* Restore ScrollLock */ - if (GetKeyState(VK_SCROLL) & 0x0001) { - winSendKeyEvent(KEY_ScrollLock, TRUE); - winSendKeyEvent(KEY_ScrollLock, FALSE); - } - - /* Restore KanaLock */ - if (GetKeyState(VK_KANA) & 0x0001) { - winSendKeyEvent(KEY_HKTG, TRUE); - winSendKeyEvent(KEY_HKTG, FALSE); - } -} - -/* - * Upon regaining the keyboard focus we must - * resynchronize our internal mode key states - * with the actual state of the keys. - */ - -void -winRestoreModeKeyStates(void) -{ - DWORD dwKeyState; - BOOL processEvents = TRUE; - unsigned short internalKeyStates; - - /* X server is being initialized */ - if (!inputInfo.keyboard || !inputInfo.keyboard->key) - 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); - - /* Check if modifier keys are pressed, and if so, fake a press */ - { - - BOOL lctrl = (GetAsyncKeyState(VK_LCONTROL) < 0); - BOOL rctrl = (GetAsyncKeyState(VK_RCONTROL) < 0); - BOOL lshift = (GetAsyncKeyState(VK_LSHIFT) < 0); - BOOL rshift = (GetAsyncKeyState(VK_RSHIFT) < 0); - BOOL alt = (GetAsyncKeyState(VK_LMENU) < 0); - BOOL altgr = (GetAsyncKeyState(VK_RMENU) < 0); - - /* - If AltGr and CtrlL appear to be pressed, assume the - CtrL is a fake one - */ - if (lctrl && altgr) - lctrl = FALSE; - - if (lctrl) - winSendKeyEvent(KEY_LCtrl, TRUE); - - if (rctrl) - winSendKeyEvent(KEY_RCtrl, TRUE); - - if (lshift) - winSendKeyEvent(KEY_ShiftL, TRUE); - - if (rshift) - winSendKeyEvent(KEY_ShiftL, TRUE); - - if (alt) - winSendKeyEvent(KEY_Alt, TRUE); - - if (altgr) - winSendKeyEvent(KEY_AltLang, TRUE); - } - - /* - Check if latching modifier key states have changed, and if so, - fake a press and a release to toggle the modifier to the correct - state - */ - dwKeyState = GetKeyState(VK_NUMLOCK) & 0x0001; - if (LOGICAL_XOR(internalKeyStates & NumLockMask, dwKeyState)) { - winSendKeyEvent(KEY_NumLock, TRUE); - winSendKeyEvent(KEY_NumLock, FALSE); - } - - dwKeyState = GetKeyState(VK_CAPITAL) & 0x0001; - if (LOGICAL_XOR(internalKeyStates & LockMask, dwKeyState)) { - winSendKeyEvent(KEY_CapsLock, TRUE); - winSendKeyEvent(KEY_CapsLock, FALSE); - } - - dwKeyState = GetKeyState(VK_SCROLL) & 0x0001; - if (LOGICAL_XOR(internalKeyStates & ScrollLockMask, dwKeyState)) { - winSendKeyEvent(KEY_ScrollLock, TRUE); - winSendKeyEvent(KEY_ScrollLock, FALSE); - } - - dwKeyState = GetKeyState(VK_KANA) & 0x0001; - if (LOGICAL_XOR(internalKeyStates & KanaMask, dwKeyState)) { - winSendKeyEvent(KEY_HKTG, TRUE); - winSendKeyEvent(KEY_HKTG, FALSE); - } - - /* - For strict correctness, we should also press any non-modifier keys - which are already down when we gain focus, but nobody has complained - yet :-) - */ -} - -/* - * Look for the lovely fake Control_L press/release generated by Windows - * when AltGr is pressed/released on a non-U.S. keyboard. - */ - -Bool -winIsFakeCtrl_L(UINT message, WPARAM wParam, LPARAM lParam) -{ - MSG msgNext; - LONG lTime; - Bool fReturn; - - static Bool lastWasControlL = FALSE; - 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; - lastTime = lTime; - } - 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; - } - } - /* - * 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); - } - 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; - } - } - 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; -} - -/* - * Lift any modifier keys that are pressed - */ - -void -winKeybdReleaseKeys(void) -{ - int i; - -#ifdef HAS_DEVWINDOWS - /* Verify that the mi input system has been initialized */ - if (g_fdMessageQueue == WIN_FD_INVALID) - return; -#endif - - /* Loop through all keys */ - for (i = 0; i < NUM_KEYCODES; ++i) { - /* Pop key if pressed */ - if (g_winKeyState[i]) - winSendKeyEvent(i, FALSE); - - /* Reset pressed flag for keys */ - g_winKeyState[i] = FALSE; - } -} - -/* - * Take a raw X key code and send an up or down event for it. - * - * Thanks to VNC for inspiration, though it is a simple function. - */ - -void -winSendKeyEvent(DWORD dwKey, Bool fDown) -{ - /* - * When alt-tabing between screens we can get phantom key up messages - * Here we only pass them through it we think we should! - */ - if (g_winKeyState[dwKey] == FALSE && fDown == FALSE) - return; - - /* Update the keyState map */ - g_winKeyState[dwKey] = fDown; - - QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, - dwKey + MIN_KEYCODE); - - winDebug("winSendKeyEvent: dwKey: %u, fDown: %u\n", (unsigned int)dwKey, fDown); -} - -BOOL -winCheckKeyPressed(WPARAM wParam, LPARAM lParam) -{ - switch (wParam) { - case VK_CONTROL: - if ((lParam & 0x1ff0000) == 0x11d0000 && g_winKeyState[KEY_RCtrl]) - return TRUE; - if ((lParam & 0x1ff0000) == 0x01d0000 && g_winKeyState[KEY_LCtrl]) - return TRUE; - break; - case VK_SHIFT: - if ((lParam & 0x1ff0000) == 0x0360000 && g_winKeyState[KEY_ShiftR]) - return TRUE; - if ((lParam & 0x1ff0000) == 0x02a0000 && g_winKeyState[KEY_ShiftL]) - return TRUE; - break; - default: - return TRUE; - } - return FALSE; -} - -/* Only one shift release message is sent even if both are pressed. - * Fix this here - */ -void -winFixShiftKeys(int iScanCode) -{ - if (GetKeyState(VK_SHIFT) & 0x8000) - return; - - if (iScanCode == KEY_ShiftL && g_winKeyState[KEY_ShiftR]) - winSendKeyEvent(KEY_ShiftR, FALSE); - if (iScanCode == KEY_ShiftR && g_winKeyState[KEY_ShiftL]) - winSendKeyEvent(KEY_ShiftL, FALSE); -} diff --git a/hw/xwin/winkeybd.h b/hw/xwin/winkeybd.h deleted file mode 100644 index 6701f0959..000000000 --- a/hw/xwin/winkeybd.h +++ /dev/null @@ -1,308 +0,0 @@ -#if !defined(WINKEYBD_H) -#define WINKEYBD_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: Harold L Hunt II - */ - -/* - * We need symbols for the scan codes of keys. - */ -#include "winkeynames.h" - -#define VK_FN 0xFF - -#define WIN_KEYMAP_COLS 3 - -/* Rows 160 through 165 correspond to software-generated codes, which - * may not be associated with the appropriate scan code. - */ -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, 0, KEY_PgUp, - /* 34 */ VK_NEXT, 0, KEY_PgDown, - /* 35 */ VK_END, 0, KEY_End, - /* 36 */ VK_HOME, 0, KEY_Home, - /* 37 */ VK_LEFT, 0, KEY_Left, - /* 38 */ VK_UP, 0, KEY_Up, - /* 39 */ VK_RIGHT, 0, KEY_Right, - /* 40 */ VK_DOWN, 0, 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, 0, - /* 161 */ VK_RSHIFT, KEY_ShiftR, 0, - /* 162 */ VK_LCONTROL, KEY_LCtrl, 0, - /* 163 */ VK_RCONTROL, KEY_RCtrl, 0, - /* 164 */ VK_LMENU, KEY_Alt, 0, - /* 165 */ VK_RMENU, KEY_AltLang, 0, - /* 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 */ diff --git a/hw/xwin/winkeyhook.c b/hw/xwin/winkeyhook.c deleted file mode 100644 index bb99c3e25..000000000 --- a/hw/xwin/winkeyhook.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - *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(); - - 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; - } - - /* Pass keystrokes on to our main message loop */ - if (iCode == HC_ACTION) { - winDebug("winKeyboardMessageHook: vkCode: %08x scanCode: %08x\n", - (unsigned int)p->vkCode, (unsigned int)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) -{ - /* 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/hw/xwin/winkeynames.h b/hw/xwin/winkeynames.h deleted file mode 100644 index 2ac1c8c97..000000000 --- a/hw/xwin/winkeynames.h +++ /dev/null @@ -1,206 +0,0 @@ -#ifndef _WINKEYNAMES_H -#define _WINKEYNAMES_H -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Thomas Roell not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Thomas Roell makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#define GLYPHS_PER_KEY 4 -#define NUM_KEYCODES 248 -#define MIN_KEYCODE 8 -#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1) - -#define AltMask Mod1Mask -#define NumLockMask Mod2Mask -#define AltLangMask Mod3Mask -#define KanaMask Mod4Mask -#define ScrollLockMask Mod5Mask - -#define ModifierDown(k) ((keyc->state & (k)) == (k)) - -/* - * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three) - * sets of scancodes. Set3 can only be generated by a MF keyboard. - * Set2 sends a makecode for keypress, and the same code prefixed by a - * F0 for keyrelease. This is a little bit ugly to handle. Thus we use - * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes. - * Bit 7 is set if the key is released. The code E0 switches to a - * different meaning to add the new MF cursorkeys, while not breaking old - * applications. E1 is another special prefix. Since I assume that there - * will be further versions of PC/XT scancode compatible keyboards, we - * may be in trouble one day. - * - * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3. - * 2) Use the keyboards native set and translate it to common keysyms. - */ - -/* - * definition of the AT84/MF101/MF102 Keyboard: - * ============================================================ - * Defined Key Cap Glyphs Pressed value - * Key Name Main Also (hex) (dec) - * ---------------- ---------- ------- ------ ------ - */ - -#define KEY_Escape /* Escape 0x01 */ 1 -#define KEY_1 /* 1 ! 0x02 */ 2 -#define KEY_2 /* 2 @ 0x03 */ 3 -#define KEY_3 /* 3 # 0x04 */ 4 -#define KEY_4 /* 4 $ 0x05 */ 5 -#define KEY_5 /* 5 % 0x06 */ 6 -#define KEY_6 /* 6 ^ 0x07 */ 7 -#define KEY_7 /* 7 & 0x08 */ 8 -#define KEY_8 /* 8 * 0x09 */ 9 -#define KEY_9 /* 9 ( 0x0a */ 10 -#define KEY_0 /* 0 ) 0x0b */ 11 -#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12 -#define KEY_Equal /* = (Equal) + 0x0d */ 13 -#define KEY_BackSpace /* Back Space 0x0e */ 14 -#define KEY_Tab /* Tab 0x0f */ 15 -#define KEY_Q /* Q 0x10 */ 16 -#define KEY_W /* W 0x11 */ 17 -#define KEY_E /* E 0x12 */ 18 -#define KEY_R /* R 0x13 */ 19 -#define KEY_T /* T 0x14 */ 20 -#define KEY_Y /* Y 0x15 */ 21 -#define KEY_U /* U 0x16 */ 22 -#define KEY_I /* I 0x17 */ 23 -#define KEY_O /* O 0x18 */ 24 -#define KEY_P /* P 0x19 */ 25 -#define KEY_LBrace /* [ { 0x1a */ 26 -#define KEY_RBrace /* ] } 0x1b */ 27 -#define KEY_Enter /* Enter 0x1c */ 28 -#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29 -#define KEY_A /* A 0x1e */ 30 -#define KEY_S /* S 0x1f */ 31 -#define KEY_D /* D 0x20 */ 32 -#define KEY_F /* F 0x21 */ 33 -#define KEY_G /* G 0x22 */ 34 -#define KEY_H /* H 0x23 */ 35 -#define KEY_J /* J 0x24 */ 36 -#define KEY_K /* K 0x25 */ 37 -#define KEY_L /* L 0x26 */ 38 -#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39 -#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40 -#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41 -#define KEY_ShiftL /* Shift(left) 0x2a */ 42 -#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43 -#define KEY_Z /* Z 0x2c */ 44 -#define KEY_X /* X 0x2d */ 45 -#define KEY_C /* C 0x2e */ 46 -#define KEY_V /* V 0x2f */ 47 -#define KEY_B /* B 0x30 */ 48 -#define KEY_N /* N 0x31 */ 49 -#define KEY_M /* M 0x32 */ 50 -#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51 -#define KEY_Period /* . (Period) >(Greater)0x34 */ 52 -#define KEY_Slash /* / (Slash) ? 0x35 */ 53 -#define KEY_ShiftR /* Shift(right) 0x36 */ 54 -#define KEY_KP_Multiply /* * 0x37 */ 55 -#define KEY_Alt /* Alt(left) 0x38 */ 56 -#define KEY_Space /* (SpaceBar) 0x39 */ 57 -#define KEY_CapsLock /* CapsLock 0x3a */ 58 -#define KEY_F1 /* F1 0x3b */ 59 -#define KEY_F2 /* F2 0x3c */ 60 -#define KEY_F3 /* F3 0x3d */ 61 -#define KEY_F4 /* F4 0x3e */ 62 -#define KEY_F5 /* F5 0x3f */ 63 -#define KEY_F6 /* F6 0x40 */ 64 -#define KEY_F7 /* F7 0x41 */ 65 -#define KEY_F8 /* F8 0x42 */ 66 -#define KEY_F9 /* F9 0x43 */ 67 -#define KEY_F10 /* F10 0x44 */ 68 -#define KEY_NumLock /* NumLock 0x45 */ 69 -#define KEY_ScrollLock /* ScrollLock 0x46 */ 70 -#define KEY_KP_7 /* 7 Home 0x47 */ 71 -#define KEY_KP_8 /* 8 Up 0x48 */ 72 -#define KEY_KP_9 /* 9 PgUp 0x49 */ 73 -#define KEY_KP_Minus /* - (Minus) 0x4a */ 74 -#define KEY_KP_4 /* 4 Left 0x4b */ 75 -#define KEY_KP_5 /* 5 0x4c */ 76 -#define KEY_KP_6 /* 6 Right 0x4d */ 77 -#define KEY_KP_Plus /* + (Plus) 0x4e */ 78 -#define KEY_KP_1 /* 1 End 0x4f */ 79 -#define KEY_KP_2 /* 2 Down 0x50 */ 80 -#define KEY_KP_3 /* 3 PgDown 0x51 */ 81 -#define KEY_KP_0 /* 0 Insert 0x52 */ 82 -#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83 -#define KEY_SysReqest /* SysReqest 0x54 */ 84 -#define KEY_Fn /* Fn 0x55 */ 85 -#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86 -#define KEY_F11 /* F11 0x57 */ 87 -#define KEY_F12 /* F12 0x58 */ 88 - -#define KEY_Prefix0 /* special 0x60 */ 96 -#define KEY_Prefix1 /* special 0x61 */ 97 - -/* - * The 'scancodes' below are generated by the server, because the MF101/102 - * keyboard sends them as sequence of other scancodes - */ -#define KEY_Home /* Home 0x59 */ 89 -#define KEY_Up /* Up 0x5a */ 90 -#define KEY_PgUp /* PgUp 0x5b */ 91 -#define KEY_Left /* Left 0x5c */ 92 -#define KEY_Begin /* Begin 0x5d */ 93 -#define KEY_Right /* Right 0x5e */ 94 -#define KEY_End /* End 0x5f */ 95 -#define KEY_Down /* Down 0x60 */ 96 -#define KEY_PgDown /* PgDown 0x61 */ 97 -#define KEY_Insert /* Insert 0x62 */ 98 -#define KEY_Delete /* Delete 0x63 */ 99 -#define KEY_KP_Enter /* Enter 0x64 */ 100 -#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101 -#define KEY_Pause /* Pause 0x66 */ 102 -#define KEY_Print /* Print 0x67 */ 103 -#define KEY_KP_Divide /* Divide 0x68 */ 104 -#define KEY_AltLang /* AtlLang(right) 0x69 */ 105 -#define KEY_Break /* Break 0x6a */ 106 -#define KEY_LMeta /* Left Meta 0x6b */ 107 -#define KEY_RMeta /* Right Meta 0x6c */ 108 -#define KEY_Menu /* Menu 0x6d */ 109 -#define KEY_F13 /* F13 0x6e */ 110 -#define KEY_F14 /* F14 0x6f */ 111 -#define KEY_F15 /* F15 0x70 */ 112 -#define KEY_F16 /* F16 0x71 */ 113 -#define KEY_F17 /* F17 0x72 */ 114 -#define KEY_KP_DEC /* KP_DEC 0x73 */ 115 -#define KEY_KP_Equal /* Equal (Keypad) 0x76 */ 118 -#define KEY_XFER /* Kanji Transfer 0x79 */ 121 -#define KEY_NFER /* No Kanji Transfer 0x7b */ 123 -#define KEY_Yen /* Yen 0x7d */ 125 -#define KEY_HKTG /* Hirugana/Katakana tog 0xc8 */ 200 -#define KEY_BSlash2 /* \ _ 0xcb */ 203 - -#define KEY_Mute /* Audio Mute */ 152 -#define KEY_AudioLower /* Audio Lower */ 166 -#define KEY_AudioRaise /* Audio Raise */ 168 - -#define KEY_NEXTSONG /* Media next */ 145 -#define KEY_PLAYPAUSE /* Media play/pause toggle */ 154 -#define KEY_PREVIOUSSONG /* Media previous */ 136 -#define KEY_STOPCD /* Media stop */ 156 - -/* These are for "notused" and "unknown" entries in translation maps. */ -#define KEY_NOTUSED 0 -#define KEY_UNKNOWN 255 - -#endif /* _WINKEYNAMES_H */ diff --git a/hw/xwin/winlayouts.h b/hw/xwin/winlayouts.h deleted file mode 100644 index 904410a2d..000000000 --- a/hw/xwin/winlayouts.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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; - const char *xkbmodel; - const char *xkblayout; - const char *xkbvariant; - const char *xkboptions; - const char *layoutname; -} WinKBLayoutRec, *WinKBLayoutPtr; - -/* - This table is sorted by low byte of winlayout, then by next byte, etc. -*/ - -WinKBLayoutRec winKBLayouts[] = { - {0x00000404, -1, "pc105", "cn", NULL, NULL, "Chinese (Traditional)"}, - {0x00000804, -1, "pc105", "cn", NULL, NULL, "Chinese (Simplified)"}, - {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)"}, - {0x00000411, 7, "jp106", "jp", NULL, NULL, "Japanese"}, - {0x00000412, -1, "kr106", "kr", NULL, NULL, "Korean"}, - {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)"}, - {0x00000419, -1, "pc105", "ru", NULL, NULL, "Russian"}, - {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/hw/xwin/winmessages.h b/hw/xwin/winmessages.h deleted file mode 100644 index 8282f8b06..000000000 --- a/hw/xwin/winmessages.h +++ /dev/null @@ -1,1031 +0,0 @@ -#ifndef __WINMESSAGES_H__ -#define __WINMESSAGES_H__ -static const unsigned MESSAGE_NAMES_LEN = 1024; - -static const char *MESSAGE_NAMES[1024] = { - "WM_NULL", - "WM_CREATE", - "WM_DESTROY", - "WM_MOVE", - "4", - "WM_SIZE", - "WM_ACTIVATE", - "WM_SETFOCUS", - "WM_KILLFOCUS", - "9", - "WM_ENABLE", - "WM_SETREDRAW", - "WM_SETTEXT", - "WM_GETTEXT", - "WM_GETTEXTLENGTH", - "WM_PAINT", - "WM_CLOSE", - "WM_QUERYENDSESSION", - "WM_QUIT", - "WM_QUERYOPEN", - "WM_ERASEBKGND", - "WM_SYSCOLORCHANGE", - "WM_ENDSESSION", - "23", - "WM_SHOWWINDOW", - "25", - "WM_WININICHANGE", - "WM_DEVMODECHANGE", - "WM_ACTIVATEAPP", - "WM_FONTCHANGE", - "WM_TIMECHANGE", - "WM_CANCELMODE", - NULL /* WM_SETCURSOR */ , - "WM_MOUSEACTIVATE", - "WM_CHILDACTIVATE", - "WM_QUEUESYNC", - "WM_GETMINMAXINFO", - "37", - "WM_PAINTICON", - "WM_ICONERASEBKGND", - "WM_NEXTDLGCTL", - "41", - "WM_SPOOLERSTATUS", - "WM_DRAWITEM", - "WM_MEASUREITEM", - "WM_DELETEITEM", - "WM_VKEYTOITEM", - "WM_CHARTOITEM", - "WM_SETFONT", - "WM_GETFONT", - "WM_SETHOTKEY", - "WM_GETHOTKEY", - "52", - "53", - "54", - "WM_QUERYDRAGICON", - "56", - "WM_COMPAREITEM", - "58", - "59", - "60", - "61", - "62", - "63", - "64", - "WM_COMPACTING", - "66", - "67", - "WM_COMMNOTIFY", - "69", - "WM_WINDOWPOSCHANGING", - "WM_WINDOWPOSCHANGED", - "WM_POWER", - "73", - "WM_COPYDATA", - "WM_CANCELJOURNAL", - "76", - "77", - "WM_NOTIFY", - "79", - "WM_INPUTLANGCHANGEREQUEST", - "WM_INPUTLANGCHANGE", - "WM_TCARD", - "WM_HELP", - "WM_USERCHANGED", - "WM_NOTIFYFORMAT", - "86", - "87", - "88", - "89", - "90", - "91", - "92", - "93", - "94", - "95", - "96", - "97", - "98", - "99", - "100", - "101", - "102", - "103", - "104", - "105", - "106", - "107", - "108", - "109", - "110", - "111", - "112", - "113", - "114", - "115", - "116", - "117", - "118", - "119", - "120", - "121", - "122", - "WM_CONTEXTMENU", - "WM_STYLECHANGING", - "WM_STYLECHANGED", - "WM_DISPLAYCHANGE", - "WM_GETICON", - "WM_SETICON", - "WM_NCCREATE", - "WM_NCDESTROY", - "WM_NCCALCSIZE", - NULL /* WM_NCHITTEST */ , - "WM_NCPAINT", - "WM_NCACTIVATE", - "WM_GETDLGCODE", - "WM_SYNCPAINT", - "137", - "138", - "139", - "140", - "141", - "142", - "143", - "144", - "145", - "146", - "147", - "148", - "149", - "150", - "151", - "152", - "153", - "154", - "155", - "156", - "157", - "158", - "159", - NULL /* WM_NCMOUSEMOVE */ , - "WM_NCLBUTTONDOWN", - "WM_NCLBUTTONUP", - "WM_NCLBUTTONDBLCLK", - "WM_NCRBUTTONDOWN", - "WM_NCRBUTTONUP", - "WM_NCRBUTTONDBLCLK", - "WM_NCMBUTTONDOWN", - "WM_NCMBUTTONUP", - "WM_NCMBUTTONDBLCLK", - "170", - "171", - "172", - "173", - "174", - "175", - "176", - "177", - "178", - "179", - "180", - "181", - "182", - "183", - "184", - "185", - "186", - "187", - "188", - "189", - "190", - "191", - "192", - "193", - "194", - "195", - "196", - "197", - "198", - "199", - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "209", - "210", - "211", - "212", - "213", - "214", - "215", - "216", - "217", - "218", - "219", - "220", - "221", - "222", - "223", - "224", - "225", - "226", - "227", - "228", - "229", - "230", - "231", - "232", - "233", - "234", - "235", - "236", - "237", - "238", - "239", - "240", - "241", - "242", - "243", - "244", - "245", - "246", - "247", - "248", - "249", - "250", - "251", - "252", - "253", - "254", - "255", - "WM_KEYDOWN", - "WM_KEYUP", - "WM_CHAR", - "WM_DEADCHAR", - "WM_SYSKEYDOWN", - "WM_SYSKEYUP", - "WM_SYSCHAR", - "WM_SYSDEADCHAR", - "WM_CONVERTREQUESTEX", - "265", - "266", - "267", - "268", - "WM_IME_STARTCOMPOSITION", - "WM_IME_ENDCOMPOSITION", - "WM_IME_KEYLAST", - "WM_INITDIALOG", - "WM_COMMAND", - "WM_SYSCOMMAND", - NULL /* WM_TIMER */ , - "WM_HSCROLL", - "WM_VSCROLL", - "WM_INITMENU", - "WM_INITMENUPOPUP", - "280", - "281", - "282", - "283", - "284", - "285", - "286", - "WM_MENUSELECT", - "WM_MENUCHAR", - "WM_ENTERIDLE", - "290", - "291", - "292", - "293", - "294", - "295", - "296", - "297", - "298", - "299", - "300", - "301", - "302", - "303", - "304", - "305", - "WM_CTLCOLORMSGBOX", - "WM_CTLCOLOREDIT", - "WM_CTLCOLORLISTBOX", - "WM_CTLCOLORBTN", - "WM_CTLCOLORDLG", - "WM_CTLCOLORSCROLLBAR", - "WM_CTLCOLORSTATIC", - "313", - "314", - "315", - "316", - "317", - "318", - "319", - "320", - "321", - "322", - "323", - "324", - "325", - "326", - "327", - "328", - "329", - "330", - "331", - "332", - "333", - "334", - "335", - "336", - "337", - "338", - "339", - "340", - "341", - "342", - "343", - "344", - "345", - "346", - "347", - "348", - "349", - "350", - "351", - "352", - "353", - "354", - "355", - "356", - "357", - "358", - "359", - "360", - "361", - "362", - "363", - "364", - "365", - "366", - "367", - "368", - "369", - "370", - "371", - "372", - "373", - "374", - "375", - "376", - "377", - "378", - "379", - "380", - "381", - "382", - "383", - "384", - "385", - "386", - "387", - "388", - "389", - "390", - "391", - "392", - "393", - "394", - "395", - "396", - "397", - "398", - "399", - "400", - "401", - "402", - "403", - "404", - "405", - "406", - "407", - "408", - "409", - "410", - "411", - "412", - "413", - "414", - "415", - "416", - "417", - "418", - "419", - "420", - "421", - "422", - "423", - "424", - "425", - "426", - "427", - "428", - "429", - "430", - "431", - "432", - "433", - "434", - "435", - "436", - "437", - "438", - "439", - "440", - "441", - "442", - "443", - "444", - "445", - "446", - "447", - "448", - "449", - "450", - "451", - "452", - "453", - "454", - "455", - "456", - "457", - "458", - "459", - "460", - "461", - "462", - "463", - "464", - "465", - "466", - "467", - "468", - "469", - "470", - "471", - "472", - "473", - "474", - "475", - "476", - "477", - "478", - "479", - "480", - "481", - "482", - "483", - "484", - "485", - "486", - "487", - "488", - "489", - "490", - "491", - "492", - "493", - "494", - "495", - "496", - "497", - "498", - "499", - "500", - "501", - "502", - "503", - "504", - "505", - "506", - "507", - "508", - "509", - "510", - "511", - NULL /* WM_MOUSEMOVE */ , - "WM_LBUTTONDOWN", - "WM_LBUTTONUP", - "WM_LBUTTONDBLCLK", - "WM_RBUTTONDOWN", - "WM_RBUTTONUP", - "WM_RBUTTONDBLCLK", - "WM_MBUTTONDOWN", - "WM_MBUTTONUP", - "WM_MBUTTONDBLCLK", - "WM_MOUSEWHEEL", - "WM_XBUTTONDOWN", - "WM_XBUTTONUP", - "WM_XBUTTONDBLCLK", - "WM_MOUSEHWHEEL", - "527", - "WM_PARENTNOTIFY", - "WM_ENTERMENULOOP", - "WM_EXITMENULOOP", - "WM_NEXTMENU", - "WM_SIZING", - "WM_CAPTURECHANGED", - "WM_MOVING", - "535", - "WM_POWERBROADCAST", - "WM_DEVICECHANGE", - "538", - "539", - "540", - "541", - "542", - "543", - "WM_MDICREATE", - "WM_MDIDESTROY", - "WM_MDIACTIVATE", - "WM_MDIRESTORE", - "WM_MDINEXT", - "WM_MDIMAXIMIZE", - "WM_MDITILE", - "WM_MDICASCADE", - "WM_MDIICONARRANGE", - "WM_MDIGETACTIVE", - "554", - "555", - "556", - "557", - "558", - "559", - "WM_MDISETMENU", - "WM_ENTERSIZEMOVE", - "WM_EXITSIZEMOVE", - "WM_DROPFILES", - "WM_MDIREFRESHMENU", - "565", - "566", - "567", - "568", - "569", - "570", - "571", - "572", - "573", - "574", - "575", - "576", - "577", - "578", - "579", - "580", - "581", - "582", - "583", - "584", - "585", - "586", - "587", - "588", - "589", - "590", - "591", - "592", - "593", - "594", - "595", - "596", - "597", - "598", - "599", - "600", - "601", - "602", - "603", - "604", - "605", - "606", - "607", - "608", - "609", - "610", - "611", - "612", - "613", - "614", - "615", - "616", - "617", - "618", - "619", - "620", - "621", - "622", - "623", - "624", - "625", - "626", - "627", - "628", - "629", - "630", - "631", - "632", - "633", - "634", - "635", - "636", - "637", - "638", - "639", - "640", - "WM_IME_SETCONTEXT", - "WM_IME_NOTIFY", - "WM_IME_CONTROL", - "WM_IME_COMPOSITIONFULL", - "WM_IME_SELECT", - "WM_IME_CHAR", - "647", - "648", - "649", - "650", - "651", - "652", - "653", - "654", - "655", - "WM_IME_KEYDOWN", - "WM_IME_KEYUP", - "658", - "659", - "660", - "661", - "662", - "663", - "664", - "665", - "666", - "667", - "668", - "669", - "670", - "671", - "672", - "WM_MOUSEHOVER", - "674", - "WM_MOUSELEAVE", - "676", - "677", - "678", - "679", - "680", - "681", - "682", - "683", - "684", - "685", - "686", - "687", - "688", - "689", - "690", - "691", - "692", - "693", - "694", - "695", - "696", - "697", - "698", - "699", - "700", - "701", - "702", - "703", - "704", - "705", - "706", - "707", - "708", - "709", - "710", - "711", - "712", - "713", - "714", - "715", - "716", - "717", - "718", - "719", - "720", - "721", - "722", - "723", - "724", - "725", - "726", - "727", - "728", - "729", - "730", - "731", - "732", - "733", - "734", - "735", - "736", - "737", - "738", - "739", - "740", - "741", - "742", - "743", - "744", - "745", - "746", - "747", - "748", - "749", - "750", - "751", - "752", - "753", - "754", - "755", - "756", - "757", - "758", - "759", - "760", - "761", - "762", - "763", - "764", - "765", - "766", - "767", - "WM_CUT", - "WM_COPY", - "WM_PASTE", - "WM_CLEAR", - "WM_UNDO", - "WM_RENDERFORMAT", - "WM_RENDERALLFORMATS", - "WM_DESTROYCLIPBOARD", - "WM_DRAWCLIPBOARD", - "WM_PAINTCLIPBOARD", - "WM_VSCROLLCLIPBOARD", - "WM_SIZECLIPBOARD", - "WM_ASKCBFORMATNAME", - "WM_CHANGECBCHAIN", - "WM_HSCROLLCLIPBOARD", - "WM_QUERYNEWPALETTE", - "WM_PALETTEISCHANGING", - "WM_PALETTECHANGED", - "WM_HOTKEY", - "787", - "788", - "789", - "790", - "WM_PRINT", - "WM_PRINTCLIENT", - "793", - "794", - "795", - "796", - "797", - "798", - "799", - "800", - "801", - "802", - "803", - "804", - "805", - "806", - "807", - "808", - "809", - "810", - "811", - "812", - "813", - "814", - "815", - "816", - "817", - "818", - "819", - "820", - "821", - "822", - "823", - "824", - "825", - "826", - "827", - "828", - "829", - "830", - "831", - "832", - "833", - "834", - "835", - "836", - "837", - "838", - "839", - "840", - "841", - "842", - "843", - "844", - "845", - "846", - "847", - "848", - "849", - "850", - "851", - "852", - "853", - "854", - "855", - "856", - "857", - "858", - "859", - "860", - "861", - "862", - "863", - "864", - "865", - "866", - "867", - "868", - "869", - "870", - "871", - "872", - "873", - "874", - "875", - "876", - "877", - "878", - "879", - "880", - "881", - "882", - "883", - "884", - "885", - "886", - "887", - "888", - "889", - "890", - "891", - "892", - "893", - "894", - "895", - "896", - "897", - "898", - "899", - "900", - "901", - "902", - "903", - "904", - "905", - "906", - "907", - "908", - "909", - "910", - "911", - "912", - "913", - "914", - "915", - "916", - "917", - "918", - "919", - "920", - "921", - "922", - "923", - "924", - "925", - "926", - "927", - "928", - "929", - "930", - "931", - "932", - "933", - "934", - "935", - "936", - "937", - "938", - "939", - "940", - "941", - "942", - "943", - "944", - "945", - "946", - "947", - "948", - "949", - "950", - "951", - "952", - "953", - "954", - "955", - "956", - "957", - "958", - "959", - "960", - "961", - "962", - "963", - "964", - "965", - "966", - "967", - "968", - "969", - "970", - "971", - "972", - "973", - "974", - "975", - "976", - "977", - "978", - "979", - "980", - "981", - "982", - "983", - "984", - "985", - "986", - "987", - "988", - "989", - "990", - "991", - "992", - "993", - "994", - "995", - "996", - "997", - "998", - "999", - "1000", - "1001", - "1002", - "1003", - "1004", - "1005", - "1006", - "1007", - "1008", - "1009", - "1010", - "1011", - "1012", - "1013", - "1014", - "1015", - "1016", - "1017", - "1018", - "1019", - "1020", - "1021", - "1022", - "1023" -}; -#endif diff --git a/hw/xwin/winmisc.c b/hw/xwin/winmisc.c deleted file mode 100644 index bea6290c6..000000000 --- a/hw/xwin/winmisc.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - *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" - -/* - * Count the number of one bits in a color mask. - */ - -CARD8 -winCountBits(DWORD dw) -{ - DWORD dwBits = 0; - - while (dw) { - dwBits += (dw & 1); - dw >>= 1; - } - - return dwBits; -} - -/* - * Modify the screen pixmap to point to the new framebuffer address - */ - -Bool -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"); - } - - return TRUE; -} diff --git a/hw/xwin/winmonitors.c b/hw/xwin/winmonitors.c deleted file mode 100644 index 5ff565308..000000000 --- a/hw/xwin/winmonitors.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - -Copyright 1993, 1998 The Open Group -Copyright (C) Colin Harrison 2005-2008 - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" -#include "winmonitors.h" - -/* - * getMonitorInfo - callback function used to return information from the enumeration of monitors attached - */ - -static -WINBOOL 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; - data->monitorHandle = hMonitor; - return FALSE; - } - return TRUE; -} - -Bool -QueryMonitor(int i, struct GetMonitorInfoData *data) -{ - /* prepare data */ - if (data == NULL) - return FALSE; - memset(data, 0, sizeof(*data)); - data->requestedMonitor = i; - - /* query information */ - EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data); - - return data->bMonitorSpecifiedExists; -} diff --git a/hw/xwin/winmonitors.h b/hw/xwin/winmonitors.h deleted file mode 100644 index 5fe3ecd52..000000000 --- a/hw/xwin/winmonitors.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - -Copyright 1993, 1998 The Open Group -Copyright (C) Colin Harrison 2005-2008 - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -/* data returned for monitor information */ -struct GetMonitorInfoData { - int requestedMonitor; - int monitorNum; - Bool bUserSpecifiedMonitor; - Bool bMonitorSpecifiedExists; - int monitorOffsetX; - int monitorOffsetY; - int monitorHeight; - int monitorWidth; - HMONITOR monitorHandle; -}; - -Bool QueryMonitor(int i, struct GetMonitorInfoData *data); diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c deleted file mode 100644 index aad99d9ad..000000000 --- a/hw/xwin/winmouse.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -#include "inputstr.h" -#include "exevents.h" /* for button/axes labels */ -#include "xserver-properties.h" -#include "inpututils.h" - -/* Peek the internal button mapping */ -static CARD8 const *g_winMouseButtonMap = NULL; - -/* - * Local prototypes - */ - -static void - winMouseCtrl(DeviceIntPtr pDevice, PtrCtrl * pCtrl); - -static void -winMouseCtrl(DeviceIntPtr pDevice, PtrCtrl * pCtrl) -{ -} - -/* - * See Porting Layer Definition - p. 18 - * This is known as a DeviceProc - */ - -int -winMouseProc(DeviceIntPtr pDeviceInt, int iState) -{ - int lngMouseButtons, i; - int lngWheelEvents = 4; - CARD8 *map; - DevicePtr pDevice = (DevicePtr) pDeviceInt; - Atom btn_labels[9]; - Atom axes_labels[2]; - - switch (iState) { - case DEVICE_INIT: - /* Get number of mouse buttons */ - lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); - winMsg(X_PROBED, "%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 - * TILT_LEFT:6 TILT_RIGHT:7 - * XBUTTON 1:8 XBUTTON 2:9 (most commonly 'back' and 'forward') - * ... - * - * The current Windows API only defines 2 extra buttons, so we don't - * expect more than 5 buttons to be reported, but more than that - * should be handled correctly - */ - - /* - * To map scroll wheel correctly we need at least the 3 normal buttons - */ - if (lngMouseButtons < 3) - lngMouseButtons = 3; - - /* allocate memory: - * number of buttons + 4 x mouse wheel event + 1 extra (offset for map) - */ - map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1)); - - /* initialize button map */ - map[0] = 0; - for (i = 1; i <= lngMouseButtons + lngWheelEvents; i++) - map[i] = i; - - 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); - btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK); - btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD); - - axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); - axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - - InitPointerDeviceStruct(pDevice, - map, - lngMouseButtons + lngWheelEvents, - btn_labels, - winMouseCtrl, - GetMotionHistorySize(), 2, axes_labels); - free(map); - - g_winMouseButtonMap = pDeviceInt->button->map; - break; - - case DEVICE_ON: - pDevice->on = TRUE; - break; - - case DEVICE_CLOSE: - g_winMouseButtonMap = NULL; - - case DEVICE_OFF: - pDevice->on = FALSE; - break; - } - return Success; -} - -/* Handle the mouse wheel */ -int -winMouseWheel(int *iTotalDeltaZ, int iDeltaZ, int iButtonUp, int iButtonDown) -{ - int button; - - /* Do we have any previous delta stored? */ - if ((*iTotalDeltaZ > 0 && iDeltaZ > 0) - || (*iTotalDeltaZ < 0 && iDeltaZ < 0)) { - /* Previous delta and of same sign as current delta */ - iDeltaZ += *iTotalDeltaZ; - *iTotalDeltaZ = 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 :) - */ - *iTotalDeltaZ = 0; - } - - /* - * Only process this message if the wheel has moved further than - * WHEEL_DELTA - */ - if (iDeltaZ >= WHEEL_DELTA || (-1 * iDeltaZ) >= WHEEL_DELTA) { - *iTotalDeltaZ = 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. - */ - *iTotalDeltaZ = iDeltaZ; - return 0; - } - - /* Set the button to indicate up or down wheel delta */ - if (iDeltaZ > 0) { - button = iButtonUp; - } - else { - button = iButtonDown; - } - - /* - * Flip iDeltaZ to positive, if negative, - * because always need to generate a *positive* number of - * button clicks for the Z axis. - */ - if (iDeltaZ < 0) { - iDeltaZ *= -1; - } - - /* Generate X input messages for each wheel delta we have seen */ - while (iDeltaZ--) { - /* Push the wheel button */ - winMouseButtonsSendEvent(ButtonPress, button); - - /* Release the wheel button */ - winMouseButtonsSendEvent(ButtonRelease, button); - } - - return 0; -} - -/* - * Enqueue a mouse button event - */ - -void -winMouseButtonsSendEvent(int iEventType, int iButton) -{ - ValuatorMask mask; - - if (g_winMouseButtonMap) - iButton = g_winMouseButtonMap[iButton]; - - valuator_mask_zero(&mask); - QueuePointerEvents(g_pwinPointer, iEventType, iButton, - POINTER_RELATIVE, &mask); - -#if CYGDEBUG - ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n", - iEventType, iButton); -#endif -} - -/* - * Decide what to do with a Windows mouse message - */ - -int -winMouseButtonsHandle(ScreenPtr pScreen, - int iEventType, int iButton, WPARAM wParam) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Send button events right away if emulate 3 buttons is off */ - if (pScreenInfo->iE3BTimeout == WIN_E3B_OFF) { - /* Emulate 3 buttons is off, send the button event */ - winMouseButtonsSendEvent(iEventType, iButton); - return 0; - } - - /* Emulate 3 buttons is on, let the fun begin */ - if (iEventType == ButtonPress - && pScreenPriv->iE3BCachedPress == 0 - && !pScreenPriv->fE3BFakeButton2Sent) { - /* - * Button was pressed, no press is cached, - * and there is no fake button 2 release pending. - */ - - /* Store button press type */ - pScreenPriv->iE3BCachedPress = iButton; - - /* - * Set a timer to send this button press if the other button - * is not pressed within the timeout time. - */ - SetTimer(pScreenPriv->hwndScreen, - WIN_E3B_TIMER_ID, pScreenInfo->iE3BTimeout, NULL); - } - else if (iEventType == ButtonPress - && pScreenPriv->iE3BCachedPress != 0 - && pScreenPriv->iE3BCachedPress != iButton - && !pScreenPriv->fE3BFakeButton2Sent) { - /* - * Button press is cached, other button was pressed, - * and there is no fake button 2 release pending. - */ - - /* Mouse button was cached and other button was pressed */ - KillTimer(pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID); - pScreenPriv->iE3BCachedPress = 0; - - /* Send fake middle button */ - winMouseButtonsSendEvent(ButtonPress, Button2); - - /* Indicate that a fake middle button event was sent */ - pScreenPriv->fE3BFakeButton2Sent = TRUE; - } - else if (iEventType == ButtonRelease - && pScreenPriv->iE3BCachedPress == iButton) { - /* - * Cached button was released before timer ran out, - * and before the other mouse button was pressed. - */ - KillTimer(pScreenPriv->hwndScreen, WIN_E3B_TIMER_ID); - pScreenPriv->iE3BCachedPress = 0; - - /* Send cached press, then send release */ - winMouseButtonsSendEvent(ButtonPress, iButton); - winMouseButtonsSendEvent(ButtonRelease, iButton); - } - else if (iEventType == ButtonRelease - && pScreenPriv->fE3BFakeButton2Sent && !(wParam & MK_LBUTTON) - && !(wParam & MK_RBUTTON)) { - /* - * Fake button 2 was sent and both mouse buttons have now been released - */ - pScreenPriv->fE3BFakeButton2Sent = FALSE; - - /* Send middle mouse button release */ - winMouseButtonsSendEvent(ButtonRelease, Button2); - } - else if (iEventType == ButtonRelease - && pScreenPriv->iE3BCachedPress == 0 - && !pScreenPriv->fE3BFakeButton2Sent) { - /* - * Button was release, no button is cached, - * and there is no fake button 2 release is pending. - */ - winMouseButtonsSendEvent(ButtonRelease, iButton); - } - - return 0; -} - -/** - * Enqueue a motion event. - * - */ -void -winEnqueueMotion(int x, int y) -{ - int valuators[2]; - ValuatorMask mask; - - valuators[0] = x; - valuators[1] = y; - - valuator_mask_set_range(&mask, 0, 2, valuators); - QueuePointerEvents(g_pwinPointer, MotionNotify, 0, - POINTER_ABSOLUTE | POINTER_SCREEN, &mask); - -} diff --git a/hw/xwin/winms.h b/hw/xwin/winms.h deleted file mode 100644 index 32923e503..000000000 --- a/hw/xwin/winms.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _WINMS_H_ -#define _WINMS_H_ -/* - *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 - */ - -#define DIRECTDRAW_VERSION 0x0300 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef WINVER -#define WINVER 0x0500 -#endif - -#include <X11/Xwindows.h> -#include <windowsx.h> - -#pragma push_macro("Status") -#undef Status -#define Status wStatus -#include "ddraw.h" -#pragma pop_macro("Status") - -#undef CreateWindow - -#endif /* _WINMS_H_ */ diff --git a/hw/xwin/winmsg.c b/hw/xwin/winmsg.c deleted file mode 100644 index 2ee48ce5a..000000000 --- a/hw/xwin/winmsg.c +++ /dev/null @@ -1,155 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Alexander Gottwald - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winmsg.h" -#if CYGDEBUG -#include "winmessages.h" -#endif -#include <stdarg.h> - -#ifdef XWIN_XF86CONFIG -void -winDrvMsg(int scrnIndex, MessageType type, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(type, 0, format, ap); - va_end(ap); -} - -void -winDrvMsgVerb(int scrnIndex, MessageType type, int verb, const char *format, - ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(type, verb, format, ap); - va_end(ap); -} -#endif - -void -winErrorFVerb(int verb, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(X_NONE, verb, format, ap); - va_end(ap); -} - -void -winDebug(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(X_NONE, 3, format, ap); - va_end(ap); -} - -void -winTrace(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - LogVMessageVerb(X_NONE, 10, format, ap); - va_end(ap); -} - -void -winW32Error(int verb, const char *msg) -{ - winW32ErrorEx(verb, msg, GetLastError()); -} - -void -winW32ErrorEx(int verb, 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)) { - winErrorFVerb(verb, "Unknown error in FormatMessage!\n"); - } - else { - winErrorFVerb(verb, "%s %s", msg, (char *) buffer); - LocalFree(buffer); - } -} - -#if CYGDEBUG -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%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam, - (int)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%p wParam 0x%x lParam 0x%x\n", hwnd, (int)wParam, - (int)lParam); - } - } -} -#else -void -winDebugWin32Message(const char *function, HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam) -{ -} -#endif diff --git a/hw/xwin/winmsg.h b/hw/xwin/winmsg.h deleted file mode 100644 index 02f672f08..000000000 --- a/hw/xwin/winmsg.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Alexander Gottwald - */ - -#ifndef __WIN_MSG_H__ -#define __WIN_MSG_H__ - -#include <X11/Xwindows.h> -#include <X11/Xfuncproto.h> - -/* - * Function prototypes - */ - -#ifdef XWIN_XF86CONFIG -void -winDrvMsgVerb(int scrnIndex, - MessageType type, int verb, const char *format, ...) -_X_ATTRIBUTE_PRINTF(4, 5); -void -winDrvMsg(int scrnIndex, MessageType type, const char *format, ...) -_X_ATTRIBUTE_PRINTF(3, 4); -#endif - -#define winMsg LogMessage - -void -winDebug(const char *format, ...) -_X_ATTRIBUTE_PRINTF(1, 2); -void -winTrace(const char *format, ...) -_X_ATTRIBUTE_PRINTF(1, 2); - -void -winErrorFVerb(int verb, const char *format, ...) -_X_ATTRIBUTE_PRINTF(2, 3); -void winW32Error(int verb, const char *message); -void winW32ErrorEx(int verb, const char *message, DWORD errorcode); -void winDebugWin32Message(const char *function, HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam); - -#endif diff --git a/hw/xwin/winmsgwindow.c b/hw/xwin/winmsgwindow.c deleted file mode 100644 index f5649b722..000000000 --- a/hw/xwin/winmsgwindow.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) Jon TURNEY 2011 - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" - -/* - * This is the messaging window, a hidden top-level window. We never do anything - * with it, but other programs may send messages to it. - */ - -/* - * winMsgWindowProc - Window procedure for msg window - */ - -static -LRESULT CALLBACK -winMsgWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ -#if CYGDEBUG - winDebugWin32Message("winMsgWindowProc", hwnd, message, wParam, lParam); -#endif - - switch (message) { - case WM_ENDSESSION: - if (!wParam) - return 0; /* shutdown is being cancelled */ - - /* - Send a WM_GIVEUP message to the X server thread so it wakes up if - blocked in select(), performs GiveUp(), and then notices that GiveUp() - has set the DE_TERMINATE flag so exits the msg dispatch loop. - */ - { - ScreenPtr pScreen = screenInfo.screens[0]; - - winScreenPriv(pScreen); - PostMessage(pScreenPriv->hwndScreen, WM_GIVEUP, 0, 0); - } - - /* - This process will be terminated by the system almost immediately - after the last thread with a message queue returns from processing - WM_ENDSESSION, so we cannot rely on any code executing after this - message is processed and need to wait here until ddxGiveUp() is called - and releases the termination mutex to guarantee that the lock file and - unix domain sockets have been removed - - ofc, Microsoft doesn't document this under WM_ENDSESSION, you are supposed - to read the source of CRSS to find out how it works :-) - - http://blogs.msdn.com/b/michen/archive/2008/04/04/application-termination-when-user-logs-off.aspx - */ - { - int iReturn = pthread_mutex_lock(&g_pmTerminating); - - if (iReturn != 0) { - ErrorF("winMsgWindowProc - pthread_mutex_lock () failed: %d\n", - iReturn); - } - winDebug - ("winMsgWindowProc - WM_ENDSESSION termination lock acquired\n"); - } - - return 0; - } - - return DefWindowProc(hwnd, message, wParam, lParam); -} - -static HWND -winCreateMsgWindow(void) -{ - HWND hwndMsg; - - // register window class - { - WNDCLASSEX wcx; - - wcx.cbSize = sizeof(WNDCLASSEX); - wcx.style = CS_HREDRAW | CS_VREDRAW; - wcx.lpfnWndProc = winMsgWindowProc; - wcx.cbClsExtra = 0; - wcx.cbWndExtra = 0; - wcx.hInstance = g_hInstance; - wcx.hIcon = NULL; - wcx.hCursor = 0; - wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wcx.lpszMenuName = NULL; - wcx.lpszClassName = WINDOW_CLASS_X_MSG; - wcx.hIconSm = NULL; - RegisterClassEx(&wcx); - } - - // Create the msg window. - hwndMsg = CreateWindowEx(0, // no extended styles - WINDOW_CLASS_X_MSG, // class name - "XWin Msg Window", // window name - WS_OVERLAPPEDWINDOW, // overlapped window - CW_USEDEFAULT, // default horizontal position - CW_USEDEFAULT, // default vertical position - CW_USEDEFAULT, // default width - CW_USEDEFAULT, // default height - (HWND) NULL, // no parent or owner window - (HMENU) NULL, // class menu used - GetModuleHandle(NULL), // instance handle - NULL); // no window creation data - - if (!hwndMsg) { - ErrorF("winCreateMsgWindow - Create msg window failed\n"); - return NULL; - } - - winDebug("winCreateMsgWindow - Created msg window hwnd 0x%p\n", hwndMsg); - - return hwndMsg; -} - -static void * -winMsgWindowThreadProc(void *arg) -{ - HWND hwndMsg; - - winDebug("winMsgWindowThreadProc - Hello\n"); - - hwndMsg = winCreateMsgWindow(); - if (hwndMsg) { - MSG msg; - - /* Pump the msg window message queue */ - while (GetMessage(&msg, hwndMsg, 0, 0) > 0) { -#if CYGDEBUG - winDebugWin32Message("winMsgWindowThread", msg.hwnd, msg.message, - msg.wParam, msg.lParam); -#endif - DispatchMessage(&msg); - } - } - - winDebug("winMsgWindowThreadProc - Exit\n"); - - return NULL; -} - -Bool -winCreateMsgWindowThread(void) -{ - pthread_t ptMsgWindowThreadProc; - - /* Spawn a thread for the msg window */ - if (pthread_create(&ptMsgWindowThreadProc, - NULL, winMsgWindowThreadProc, NULL)) { - /* Bail if thread creation failed */ - ErrorF("winCreateMsgWindow - pthread_create failed.\n"); - return FALSE; - } - - return TRUE; -} diff --git a/hw/xwin/winmultiwindowclass.c b/hw/xwin/winmultiwindowclass.c deleted file mode 100644 index 6787332a3..000000000 --- a/hw/xwin/winmultiwindowclass.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include <X11/Xatom.h> -#include "propertyst.h" -#include "windowstr.h" -#include "winmultiwindowclass.h" -#include "win.h" - -/* - * Local function - */ - -DEFINE_ATOM_HELPER(AtmWmWindowRole, "WM_WINDOW_ROLE") - -int -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; - } - - 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) { - /* - WM_CLASS property should consist of 2 null terminated strings, but we - must handle the cases when one or both is absent or not null terminated - */ - len_name = strlen((char *) prop->data); - if (len_name > prop->size) len_name = prop->size; - - (*res_name) = malloc(len_name + 1); - - if (!*res_name) { - ErrorF("winMultiWindowGetClassHint - *res_name was NULL\n"); - return 0; - } - - /* Copy name and ensure null terminated */ - strncpy((*res_name), prop->data, len_name); - (*res_name)[len_name] = '\0'; - - /* Compute length of class name, it could be that it is absent or not null terminated */ - len_class = (len_name >= prop->size) ? 0 : (strlen(((char *) prop->data) + 1 + len_name)); - if (len_class > prop->size - 1 - len_name) len_class = prop->size - 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; - } - - /* Copy class name and ensure null terminated */ - strncpy((*res_class), ((char *) prop->data) + 1 + len_name, len_class); - (*res_class)[len_class] = '\0'; - - return 1; - } - else - prop = prop->next; - } - - return 0; -} - -int -winMultiWindowGetWMHints(WindowPtr pWin, WinXWMHints * hints) -{ - struct _Window *pwin; - struct _Property *prop; - - 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->data) { - memcpy(hints, prop->data, sizeof(WinXWMHints)); - return 1; - } - else - prop = prop->next; - } - - return 0; -} - -int -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; - } - - return 0; -} - -int -winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints) -{ - struct _Window *pwin; - struct _Property *prop; - - 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->data) { - memcpy(hints, prop->data, sizeof(WinXSizeHints)); - return 1; - } - else - prop = prop->next; - } - - return 0; -} - -int -winMultiWindowGetTransientFor(WindowPtr pWin, Window *pDaddyId) -{ - struct _Window *pwin; - struct _Property *prop; - - 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 (pDaddyId) - *pDaddyId = 0; - - while (prop) { - if (prop->propertyName == XA_WM_TRANSIENT_FOR) { - if (pDaddyId) - memcpy(pDaddyId, prop->data, sizeof(Window)); - return 1; - } - else - prop = prop->next; - } - - return 0; -} - -int -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; - } - - 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; -} diff --git a/hw/xwin/winmultiwindowclass.h b/hw/xwin/winmultiwindowclass.h deleted file mode 100644 index 37ee9fb13..000000000 --- a/hw/xwin/winmultiwindowclass.h +++ /dev/null @@ -1,135 +0,0 @@ -#if !defined(WINMULTIWINDOWCLASS_H) -#define WINMULTIWINDOWCLASS_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: Earle F. Philhower, III - */ - -/* - * The next block of definitions are for window manager properties that - * clients and applications use for communication. - */ - -/* - * Structures - */ - -/* - * WM_HINTS structure - * - * NOTE: this structure represents the internal format stored in the property - * after it is marshalled by libX11, converting the flags field from an - * arch-dependent long to a 32-bit int. - */ - -typedef struct { - int flags; /* marks which fields in this structure are defined */ - Bool input; /* does this application rely on the window manager to - get keyboard input? */ - int initial_state; /* see below */ - Pixmap icon_pixmap; /* pixmap to be used as icon */ - Window icon_window; /* window to be used as icon */ - int icon_x, icon_y; /* initial position of icon */ - Pixmap icon_mask; /* icon mask bitmap */ - XID window_group; /* id of related window group */ - /* this structure may be extended in the future */ -} WinXWMHints; - -/* Window manager hints mask bits */ -#define InputHint (1L << 0) -#define StateHint (1L << 1) -#define IconPixmapHint (1L << 2) -#define IconWindowHint (1L << 3) -#define IconPositionHint (1L << 4) -#define IconMaskHint (1L << 5) -#define WindowGroupHint (1L << 6) -#define UrgencyHint (1L << 8) -#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint|IconPositionHint|IconMaskHint|WindowGroupHint) - -/* - * ICCCM 1.0 version containing base_width, base_height, and win_gravity fields; - * used with WM_NORMAL_HINTS. - * - * NOTE: this structure represents the internal format stored in the property - * after it is marshalled by libX11, converting the flags field from an - * arch-dependent long to a 32-bit int. - */ -typedef struct { - int flags; /* marks which fields in this structure are defined */ - int x, y; /* obsolete for new window mgrs, but clients */ - int width, height; /* should set so old wm's don't mess up */ - int min_width, min_height; - int max_width, max_height; - int width_inc, height_inc; - struct { - int x; /* numerator */ - int y; /* denominator */ - } min_aspect, max_aspect; - int base_width, base_height; /* added by ICCCM version 1 */ - int win_gravity; /* added by ICCCM version 1 */ -} WinXSizeHints; - -/* flags argument in size hints */ -#define USPosition (1L << 0) /* user specified x, y */ -#define USSize (1L << 1) /* user specified width, height */ - -#define PPosition (1L << 2) /* program specified position */ -#define PSize (1L << 3) /* program specified size */ -#define PMinSize (1L << 4) /* program specified minimum size */ -#define PMaxSize (1L << 5) /* program specified maximum size */ -#define PResizeInc (1L << 6) /* program specified resize increments */ -#define PAspect (1L << 7) /* program specified min and max aspect ratios */ -#define PBaseSize (1L << 8) /* program specified base for incrementing */ -#define PWinGravity (1L << 9) /* program specified window gravity */ - -/* obsolete */ -#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect) - -/* - * Function prototypes - */ - -int - winMultiWindowGetWMHints(WindowPtr pWin, WinXWMHints * hints); - -int - winMultiWindowGetClassHint(WindowPtr pWin, char **res_name, char **res_class); - -int - winMultiWindowGetWindowRole(WindowPtr pWin, char **res_role); - -int - winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints); - -int - winMultiWindowGetWMName(WindowPtr pWin, char **wmName); - -int - winMultiWindowGetTransientFor(WindowPtr pWin, Window *ppDaddy); - -#endif diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c deleted file mode 100644 index 0ef666d89..000000000 --- a/hw/xwin/winmultiwindowicons.c +++ /dev/null @@ -1,671 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#ifndef WINVER -#define WINVER 0x0500 -#endif - -#include <limits.h> -#include <stdbool.h> - -#include <X11/Xwindows.h> -#include <xcb/xcb.h> -#include <xcb/xcb_icccm.h> -#include <xcb/xcb_image.h> - -#include "winresource.h" -#include "winprefs.h" -#include "winmsg.h" -#include "winmultiwindowicons.h" -#include "winglobals.h" - -/* - * global variables - */ -extern HINSTANCE g_hInstance; - -/* - * Scale an X icon ZPixmap into a Windoze icon bitmap - */ - -static void -winScaleXImageToWindowsIcon(int iconSize, - int effBPP, - int stride, xcb_image_t* pixmap, unsigned char *image) -{ - int row, column, effXBPP, effXDepth; - unsigned char *outPtr; - unsigned char *iconData = 0; - int xStride; - float factX, factY; - int posX, posY; - unsigned char *ptr; - unsigned int zero; - unsigned int color; - - effXBPP = pixmap->bpp; - if (pixmap->bpp == 15) - effXBPP = 16; - - effXDepth = pixmap->depth; - if (pixmap->depth == 15) - effXDepth = 16; - - xStride = pixmap->stride; - if (stride == 0 || xStride == 0) { - ErrorF("winScaleXBitmapToWindows - stride or xStride is zero. " - "Bailing.\n"); - return; - } - - /* Get icon data */ - iconData = (unsigned char *) pixmap->data; - - /* Keep aspect ratio */ - factX = ((float) pixmap->width) / ((float) iconSize); - factY = ((float) pixmap->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->width || posY >= pixmap->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->width || posY >= pixmap->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->width || posY >= pixmap->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 */ -} - -static HICON -NetWMToWinIconAlpha(uint32_t * icon) -{ - int width = icon[0]; - int height = icon[1]; - uint32_t *pixels = &icon[2]; - HICON result; - HDC hdc = GetDC(NULL); - uint32_t *DIB_pixels; - ICONINFO ii; - BITMAPV4HEADER bmh = { sizeof(bmh) }; - - /* Define an ARGB pixel format used for Color+Alpha icons */ - bmh.bV4Width = width; - bmh.bV4Height = -height; /* Invert the image */ - bmh.bV4Planes = 1; - bmh.bV4BitCount = 32; - bmh.bV4V4Compression = BI_BITFIELDS; - bmh.bV4AlphaMask = 0xFF000000; - bmh.bV4RedMask = 0x00FF0000; - bmh.bV4GreenMask = 0x0000FF00; - bmh.bV4BlueMask = 0x000000FF; - - ii.fIcon = TRUE; - ii.xHotspot = 0; /* ignored */ - ii.yHotspot = 0; /* ignored */ - ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO *) &bmh, - DIB_RGB_COLORS, (void **) &DIB_pixels, NULL, - 0); - ReleaseDC(NULL, hdc); - - if (!ii.hbmColor) - return NULL; - - 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) */ - result = CreateIconIndirect(&ii); - - DeleteObject(ii.hbmColor); - DeleteObject(ii.hbmMask); - - winDebug("NetWMToWinIconAlpha - %d x %d = %p\n", icon[0], icon[1], result); - return result; -} - -static HICON -NetWMToWinIconThreshold(uint32_t * icon) -{ - int width = icon[0]; - int height = icon[1]; - uint32_t *pixels = &icon[2]; - int row, col; - HICON result; - ICONINFO ii; - - HDC hdc = GetDC(NULL); - HDC xorDC = CreateCompatibleDC(hdc); - HDC andDC = CreateCompatibleDC(hdc); - - ii.fIcon = TRUE; - ii.xHotspot = 0; /* ignored */ - ii.yHotspot = 0; /* ignored */ - 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); - - result = CreateIconIndirect(&ii); - - DeleteObject(ii.hbmColor); - DeleteObject(ii.hbmMask); - - winDebug("NetWMToWinIconThreshold - %d x %d = %p\n", icon[0], icon[1], - result); - return result; -} - -static HICON -NetWMToWinIcon(int bpp, uint32_t * icon) -{ - static bool hasIconAlphaChannel = FALSE; - static bool versionChecked = FALSE; - - if (!versionChecked) { - OSVERSIONINFOEX osvi = { 0 }; - ULONGLONG dwlConditionMask = 0; - - osvi.dwOSVersionInfoSize = sizeof(osvi); - osvi.dwMajorVersion = 5; - osvi.dwMinorVersion = 1; - - /* Windows versions later than XP have icon alpha channel support, 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; - - ErrorF("OS has icon alpha channel support: %s\n", - hasIconAlphaChannel ? "yes" : "no"); - } - - if (hasIconAlphaChannel && (bpp == 32)) - return NetWMToWinIconAlpha(icon); - else - return NetWMToWinIconThreshold(icon); -} - -/* - * Attempt to create a custom icon from the WM_HINTS bitmaps - */ - -static -HICON -winXIconToHICON(xcb_connection_t *conn, xcb_window_t id, int iconSize) -{ - unsigned char *mask, *image = NULL, *imageMask; - unsigned char *dst, *src; - int planes, bpp, i; - unsigned int biggest_size = 0; - HDC hDC; - ICONINFO ii; - xcb_icccm_wm_hints_t hints; - HICON hIcon = NULL; - uint32_t *biggest_icon = NULL; - static xcb_atom_t _XA_NET_WM_ICON; - static int generation; - uint32_t *icon, *icon_data = NULL; - unsigned long int size; - - hDC = GetDC(GetDesktopWindow()); - planes = GetDeviceCaps(hDC, PLANES); - bpp = GetDeviceCaps(hDC, BITSPIXEL); - ReleaseDC(GetDesktopWindow(), hDC); - - /* Always prefer _NET_WM_ICON icons */ - if (generation != serverGeneration) { - xcb_intern_atom_reply_t *atom_reply; - xcb_intern_atom_cookie_t atom_cookie; - const char *atomName = "_NET_WM_ICON"; - - generation = serverGeneration; - - _XA_NET_WM_ICON = XCB_NONE; - - atom_cookie = xcb_intern_atom(conn, 0, strlen(atomName), atomName); - atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL); - if (atom_reply) { - _XA_NET_WM_ICON = atom_reply->atom; - free(atom_reply); - } - } - - { - xcb_get_property_cookie_t cookie = xcb_get_property(conn, FALSE, id, _XA_NET_WM_ICON, XCB_ATOM_CARDINAL, 0L, INT_MAX); - xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie, NULL); - - if (reply && - ((icon_data = xcb_get_property_value(reply)) != NULL)) { - size = xcb_get_property_value_length(reply)/sizeof(uint32_t); - for (icon = icon_data; icon < &icon_data[size] && *icon; - icon = &icon[icon[0] * icon[1] + 2]) { - winDebug("winXIconToHICON: %u x %u NetIcon\n", icon[0], icon[1]); - - /* Icon data size will overflow an int and thus is bigger than the - property can possibly be */ - if ((INT_MAX/icon[0]) < icon[1]) { - winDebug("winXIconToHICON: _NET_WM_ICON icon data size overflow\n"); - break; - } - - /* Icon data size is bigger than amount of data remaining */ - if (&icon[icon[0] * icon[1] + 2] > &icon_data[size]) { - winDebug("winXIconToHICON: _NET_WM_ICON data is malformed\n"); - break; - } - - /* Found an exact match to the size we require... */ - if (icon[0] == iconSize && icon[1] == iconSize) { - winDebug("winXIconToHICON: selected %d x %d NetIcon\n", - iconSize, iconSize); - hIcon = NetWMToWinIcon(bpp, icon); - break; - } - /* Otherwise, find the biggest icon and let Windows scale the size */ - else if (biggest_size < icon[0]) { - biggest_icon = icon; - biggest_size = icon[0]; - } - } - - if (!hIcon && biggest_icon) { - winDebug - ("winXIconToHICON: selected %u x %u NetIcon for scaling to %d x %d\n", - biggest_icon[0], biggest_icon[1], iconSize, iconSize); - - hIcon = NetWMToWinIcon(bpp, biggest_icon); - } - - free(reply); - } - } - - if (!hIcon) { - xcb_get_property_cookie_t wm_hints_cookie; - - winDebug("winXIconToHICON: no suitable NetIcon\n"); - - wm_hints_cookie = xcb_icccm_get_wm_hints(conn, id); - if (xcb_icccm_get_wm_hints_reply(conn, wm_hints_cookie, &hints, NULL)) { - winDebug("winXIconToHICON: id 0x%x icon_pixmap hint 0x%x\n", - (unsigned int)id, - (unsigned int)hints.icon_pixmap); - - if (hints.icon_pixmap) { - unsigned int width, height; - xcb_image_t *xImageIcon; - xcb_image_t *xImageMask = NULL; - - xcb_get_geometry_cookie_t geom_cookie = xcb_get_geometry(conn, hints.icon_pixmap); - xcb_get_geometry_reply_t *geom_reply = xcb_get_geometry_reply(conn, geom_cookie, NULL); - - if (geom_reply) { - width = geom_reply->width; - height = geom_reply->height; - - xImageIcon = xcb_image_get(conn, hints.icon_pixmap, - 0, 0, width, height, - 0xFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); - - winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%p\n", - (unsigned int)id, xImageIcon); - - if (hints.icon_mask) - xImageMask = xcb_image_get(conn, hints.icon_mask, - 0, 0, width, height, - 0xFFFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); - - if (xImageIcon) { - int effBPP, stride, maskStride; - - /* 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); - mask = malloc(maskStride * iconSize); - - /* Default to a completely black mask */ - memset(imageMask, 0, stride * iconSize); - memset(mask, 0, maskStride * iconSize); - - winScaleXImageToWindowsIcon(iconSize, effBPP, stride, - xImageIcon, image); - - if (xImageMask) { - winScaleXImageToWindowsIcon(iconSize, 1, maskStride, - xImageMask, mask); - winScaleXImageToWindowsIcon(iconSize, effBPP, stride, - xImageMask, 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); - - if (xImageMask) - xcb_image_destroy(xImageMask); - - xcb_image_destroy(xImageIcon); - } - } - } - } - } - return hIcon; -} - -/* - * Change the Windows window icon - */ - -void -winUpdateIcon(HWND hWnd, xcb_connection_t *conn, xcb_window_t id, HICON hIconNew) -{ - HICON hIcon, hIconSmall = NULL, hIconOld; - - if (hIconNew) - { - /* Start with the icon from preferences, if any */ - hIcon = hIconNew; - hIconSmall = hIconNew; - } - else - { - /* If we still need an icon, try and get the icon from WM_HINTS */ - hIcon = winXIconToHICON(conn, id, GetSystemMetrics(SM_CXICON)); - hIconSmall = winXIconToHICON(conn, id, GetSystemMetrics(SM_CXSMICON)); - } - - /* If we got the small, but not the large one swap them */ - if (!hIcon && hIconSmall) { - hIcon = hIconSmall; - hIconSmall = NULL; - } - - /* Set the large icon */ - hIconOld = (HICON) SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon); - /* Delete the old icon if its not the default */ - winDestroyIcon(hIconOld); - - /* Same for the small icon */ - hIconOld = - (HICON) SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall); - winDestroyIcon(hIconOld); -} - -void -winInitGlobalIcons(void) -{ - int sm_cx = GetSystemMetrics(SM_CXICON); - int sm_cxsm = GetSystemMetrics(SM_CXSMICON); - - /* Load default X icon in case it's not ready yet */ - if (!g_hIconX) { - g_hIconX = winOverrideDefaultIcon(sm_cx); - g_hSmallIconX = winOverrideDefaultIcon(sm_cxsm); - } - - if (!g_hIconX) { - g_hIconX = (HICON) LoadImage(g_hInstance, - MAKEINTRESOURCE(IDI_XWIN), - IMAGE_ICON, - GetSystemMetrics(SM_CXICON), - GetSystemMetrics(SM_CYICON), 0); - g_hSmallIconX = (HICON) LoadImage(g_hInstance, - MAKEINTRESOURCE(IDI_XWIN), - IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), - GetSystemMetrics(SM_CYSMICON), - LR_DEFAULTSIZE); - } -} - -void -winSelectIcons(HICON * pIcon, HICON * pSmallIcon) -{ - HICON hIcon, hSmallIcon; - - winInitGlobalIcons(); - - /* Use default X icon */ - hIcon = g_hIconX; - hSmallIcon = g_hSmallIconX; - - if (pIcon) - *pIcon = hIcon; - - if (pSmallIcon) - *pSmallIcon = hSmallIcon; -} - -void -winDestroyIcon(HICON hIcon) -{ - /* Delete the icon if its not one of the application defaults or an override */ - if (hIcon && - hIcon != g_hIconX && - hIcon != g_hSmallIconX && !winIconIsOverride(hIcon)) - DestroyIcon(hIcon); -} diff --git a/hw/xwin/winmultiwindowicons.h b/hw/xwin/winmultiwindowicons.h deleted file mode 100644 index 8b077ab80..000000000 --- a/hw/xwin/winmultiwindowicons.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * File: winmultiwindowicons.h - * Purpose: interface for multiwindow mode icon functions - * - * Copyright (c) Jon TURNEY 2012 - * - * - * 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 WINMULTIWINDOWICONS_H -#define WINMULTIWINDOWICONS_H - -#include <xcb/xcb.h> - -void - winUpdateIcon(HWND hWnd, xcb_connection_t *conn, xcb_window_t id, HICON hIconNew); - -void - winInitGlobalIcons(void); - -void - winDestroyIcon(HICON hIcon); - -void - winSelectIcons(HICON * pIcon, HICON * pSmallIcon); - -#endif /* WINMULTIWINDOWICONS_H */ diff --git a/hw/xwin/winmultiwindowshape.c b/hw/xwin/winmultiwindowshape.c deleted file mode 100644 index 73afaea55..000000000 --- a/hw/xwin/winmultiwindowshape.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: 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); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winSetShapeMultiWindow - pWin: %p kind: %i\n", pWin, kind); -#endif - - 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); - -#if CYGDEBUG - winDebug("winReshape ()\n"); -#endif - - /* 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; -} diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c deleted file mode 100644 index 5b9b74e3d..000000000 --- a/hw/xwin/winmultiwindowwindow.c +++ /dev/null @@ -1,1218 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - *Copyright (C) Colin Harrison 2005-2008 - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Earle F. Philhower, III - * Harold L Hunt II - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" -#include "dixevents.h" -#include "winmultiwindowclass.h" -#include "winmultiwindowicons.h" - -/* - * Prototypes for local functions - */ - -void - winCreateWindowsWindow(WindowPtr pWin); - -static void - winDestroyWindowsWindow(WindowPtr pWin); - -static void - winUpdateWindowsWindow(WindowPtr pWin); - -static void - winFindWindow(void *value, XID id, void *cdata); - -static - void -winInitMultiWindowClass(void) -{ - static wATOM atomXWinClass = 0; - WNDCLASSEX wcx; - - if (atomXWinClass == 0) { - HICON hIcon, hIconSmall; - - /* Load the default icons */ - winSelectIcons(&hIcon, &hIconSmall); - - /* 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 = hIcon; - wcx.hCursor = 0; - wcx.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); - wcx.lpszMenuName = NULL; - wcx.lpszClassName = WINDOW_CLASS_X; - wcx.hIconSm = hIconSmall; - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winCreateWindowsWindow - Creating class: %s\n", WINDOW_CLASS_X); -#endif - - atomXWinClass = RegisterClassEx(&wcx); - } -} - -/* - * CreateWindow - See Porting Layer Definition - p. 37 - */ - -Bool -winCreateWindowMultiWindow(WindowPtr pWin) -{ - Bool fResult = TRUE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG - winTrace("winCreateWindowMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(CreateWindow); - fResult = (*pScreen->CreateWindow) (pWin); - WIN_WRAP(CreateWindow, winCreateWindowMultiWindow); - - /* Initialize some privates values */ - pWinPriv->hRgn = NULL; - pWinPriv->hWnd = NULL; - pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen); - pWinPriv->fXKilled = FALSE; -#ifdef XWIN_GLX_WINDOWS - pWinPriv->fWglUsed = FALSE; -#endif - - return fResult; -} - -/* - * DestroyWindow - See Porting Layer Definition - p. 37 - */ - -Bool -winDestroyWindowMultiWindow(WindowPtr pWin) -{ - Bool fResult = TRUE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winDestroyWindowMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(DestroyWindow); - fResult = (*pScreen->DestroyWindow) (pWin); - WIN_WRAP(DestroyWindow, winDestroyWindowMultiWindow); - - /* Flag that the window has been destroyed */ - pWinPriv->fXKilled = TRUE; - - /* Kill the MS Windows window associated with this window */ - winDestroyWindowsWindow(pWin); - - return fResult; -} - -/* - * PositionWindow - See Porting Layer Definition - p. 37 - * - * This function adjusts the position and size of Windows window - * with respect to the underlying X window. This is the inverse - * of winAdjustXWindow, which adjusts X window to Windows window. - */ - -Bool -winPositionWindowMultiWindow(WindowPtr pWin, int x, int y) -{ - Bool fResult = TRUE; - int iX, iY, iWidth, iHeight; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - - HWND hWnd = pWinPriv->hWnd; - RECT rcNew; - RECT rcOld; - -#if CYGMULTIWINDOW_DEBUG - RECT rcClient; - RECT *lpRc; -#endif - DWORD dwExStyle; - DWORD dwStyle; - -#if CYGMULTIWINDOW_DEBUG - winTrace("winPositionWindowMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(PositionWindow); - fResult = (*pScreen->PositionWindow) (pWin, x, y); - WIN_WRAP(PositionWindow, winPositionWindowMultiWindow); - -#if CYGWINDOWING_DEBUG - ErrorF("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n", x, y); -#endif - - /* Bail out if the Windows window handle is bad */ - if (!hWnd) { -#if CYGWINDOWING_DEBUG - ErrorF("\timmediately return since hWnd is NULL\n"); -#endif - return fResult; - } - - /* Get the Windows window style and extended style */ - dwExStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr(hWnd, GWL_STYLE); - - /* Get the X and Y location of the X window */ - iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN); - iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN); - - /* Get the height and width of the X window */ - iWidth = pWin->drawable.width; - iHeight = pWin->drawable.height; - - /* Store the origin, height, and width in a rectangle structure */ - SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight); - -#if CYGMULTIWINDOW_DEBUG - lpRc = &rcNew; - ErrorF("winPositionWindowMultiWindow - drawable (%d, %d)-(%d, %d)\n", - (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); -#endif - - /* - * Calculate the required size of the Windows window rectangle, - * given the size of the Windows window client area. - */ - AdjustWindowRectEx(&rcNew, dwStyle, FALSE, dwExStyle); - - /* Get a rectangle describing the old Windows window */ - GetWindowRect(hWnd, &rcOld); - -#if CYGMULTIWINDOW_DEBUG - /* Get a rectangle describing the Windows window client area */ - GetClientRect(hWnd, &rcClient); - - lpRc = &rcNew; - ErrorF("winPositionWindowMultiWindow - rcNew (%d, %d)-(%d, %d)\n", - (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); - - lpRc = &rcOld; - ErrorF("winPositionWindowMultiWindow - rcOld (%d, %d)-(%d, %d)\n", - (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); - - lpRc = &rcClient; - ErrorF("rcClient (%d, %d)-(%d, %d)\n", - (int)lpRc->left, (int)lpRc->top, (int)lpRc->right, (int)lpRc->bottom); -#endif - - /* Check if the old rectangle and new rectangle are the same */ - if (!EqualRect(&rcNew, &rcOld)) { -#if CYGMULTIWINDOW_DEBUG - ErrorF("winPositionWindowMultiWindow - Need to move\n"); -#endif - -#if CYGWINDOWING_DEBUG - ErrorF("\tMoveWindow to (%d, %d) - %dx%d\n", (int)rcNew.left, (int)rcNew.top, - (int)(rcNew.right - rcNew.left), (int)(rcNew.bottom - rcNew.top)); -#endif - /* Change the position and dimensions of the Windows window */ - MoveWindow(hWnd, - rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, TRUE); - } - else { -#if CYGMULTIWINDOW_DEBUG - ErrorF("winPositionWindowMultiWindow - Not need to move\n"); -#endif - } - - return fResult; -} - -/* - * ChangeWindowAttributes - See Porting Layer Definition - p. 37 - */ - -Bool -winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask) -{ - Bool fResult = TRUE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winChangeWindowAttributesMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(ChangeWindowAttributes); - fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask); - WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesMultiWindow); - - /* - * NOTE: We do not currently need to do anything here. - */ - - return fResult; -} - -/* - * UnmapWindow - See Porting Layer Definition - p. 37 - * Also referred to as UnrealizeWindow - */ - -Bool -winUnmapWindowMultiWindow(WindowPtr pWin) -{ - Bool fResult = TRUE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winUnmapWindowMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(UnrealizeWindow); - fResult = (*pScreen->UnrealizeWindow) (pWin); - WIN_WRAP(UnrealizeWindow, winUnmapWindowMultiWindow); - - /* Flag that the window has been killed */ - pWinPriv->fXKilled = TRUE; - - /* Destroy the Windows window associated with this X window */ - winDestroyWindowsWindow(pWin); - - return fResult; -} - -/* - * MapWindow - See Porting Layer Definition - p. 37 - * Also referred to as RealizeWindow - */ - -Bool -winMapWindowMultiWindow(WindowPtr pWin) -{ - Bool fResult = TRUE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMapWindowMultiWindow - pWin: %p\n", pWin); -#endif - - WIN_UNWRAP(RealizeWindow); - fResult = (*pScreen->RealizeWindow) (pWin); - WIN_WRAP(RealizeWindow, winMapWindowMultiWindow); - - /* Flag that this window has not been destroyed */ - pWinPriv->fXKilled = FALSE; - - /* Refresh/redisplay the Windows window associated with this X window */ - winUpdateWindowsWindow(pWin); - - /* Update the Windows window's shape */ - winReshapeMultiWindow(pWin); - winUpdateRgnMultiWindow(pWin); - - return fResult; -} - -/* - * ReparentWindow - See Porting Layer Definition - p. 42 - */ - -void -winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - - winDebug - ("winReparentMultiWindow - pWin:%p XID:0x%x, reparent from pWin:%p XID:0x%x to pWin:%p XID:0x%x\n", - pWin, (unsigned int)pWin->drawable.id, - pPriorParent, (unsigned int)pPriorParent->drawable.id, - pWin->parent, (unsigned int)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) -{ -#if 0 - WindowPtr pPrevWin; - UINT uFlags; - HWND hInsertAfter; - HWND hWnd = NULL; -#endif - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG - winTrace("winRestackMultiWindow - %p\n", pWin); -#endif - - WIN_UNWRAP(RestackWindow); - if (pScreen->RestackWindow) - (*pScreen->RestackWindow) (pWin, pOldNextSib); - WIN_WRAP(RestackWindow, winRestackWindowMultiWindow); - -#if 1 - /* - * Calling winReorderWindowsMultiWindow here means our window manager - * (i.e. Windows Explorer) has initiative to determine Z order. - */ - if (pWin->nextSib != pOldNextSib) - winReorderWindowsMultiWindow(); -#else - /* Bail out if no window privates or window handle is invalid */ - if (!pWinPriv || !pWinPriv->hWnd) - return; - - /* Get a pointer to our previous sibling window */ - pPrevWin = pWin->prevSib; - - /* - * Look for a sibling window with - * valid privates and window handle - */ - while (pPrevWin && !winGetWindowPriv(pPrevWin) - && !winGetWindowPriv(pPrevWin)->hWnd) - pPrevWin = pPrevWin->prevSib; - - /* Check if we found a valid sibling */ - if (pPrevWin) { - /* Valid sibling - get handle to insert window after */ - hInsertAfter = winGetWindowPriv(pPrevWin)->hWnd; - uFlags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE; - - hWnd = GetNextWindow(pWinPriv->hWnd, GW_HWNDPREV); - - do { - if (GetProp(hWnd, WIN_WINDOW_PROP)) { - if (hWnd == winGetWindowPriv(pPrevWin)->hWnd) { - uFlags |= SWP_NOZORDER; - } - break; - } - hWnd = GetNextWindow(hWnd, GW_HWNDPREV); - } - while (hWnd); - } - else { - /* No valid sibling - make this window the top window */ - hInsertAfter = HWND_TOP; - uFlags = SWP_NOMOVE | SWP_NOSIZE; - } - - /* Perform the restacking operation in Windows */ - SetWindowPos(pWinPriv->hWnd, hInsertAfter, 0, 0, 0, 0, uFlags); -#endif -} - -/* - * winCreateWindowsWindow - Create a Windows window associated with an X window - */ - -void -winCreateWindowsWindow(WindowPtr pWin) -{ - int iX, iY; - int iWidth; - int iHeight; - HWND hWnd; - HWND hFore = NULL; - - winWindowPriv(pWin); - WinXSizeHints hints; - Window daddyId; - DWORD dwStyle, dwExStyle; - RECT rc; - - winInitMultiWindowClass(); - - winDebug("winCreateWindowsTopLevelWindow - pWin:%p XID:0x%x \n", pWin, - (unsigned int)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 - - To handle arrangements of monitors which form a non-rectangular virtual - desktop, check if the window will end up with its top-left corner on any - monitor - */ - if (pWin->drawable.class != InputOnly) { - POINT pt = { iX, iY }; - if (MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) == NULL) - { - iX = CW_USEDEFAULT; - iY = CW_USEDEFAULT; - } - } - - winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, - iY); - - if (winMultiWindowGetTransientFor(pWin, &daddyId)) { - if (daddyId) { - WindowPtr pParent; - int res = dixLookupWindow(&pParent, daddyId, serverClient, DixReadAccess); - if (res == Success) - { - winPrivWinPtr pParentPriv = winGetWindowPriv(pParent); - hFore = pParentPriv->hWnd; - } - } - } - 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 preserve 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; - - /* 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); - - /* Adjust the X window to match the window placement we actually got... */ - winAdjustXWindow(pWin, hWnd); - - /* 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) (INT_PTR) winGetWindowID(pWin)); - - /* Flag that this Windows window handles its own activation */ - SetProp(hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0); -} - -Bool winInDestroyWindowsWindow = FALSE; - -/* - * winDestroyWindowsWindow - Destroy a Windows window associated - * with an X window - */ -static void -winDestroyWindowsWindow(WindowPtr pWin) -{ - MSG msg; - - winWindowPriv(pWin); - BOOL oldstate = winInDestroyWindowsWindow; - HICON hIcon; - HICON hIconSm; - - winDebug("winDestroyWindowsWindow - pWin:%p XID:0x%x \n", pWin, - (unsigned int)pWin->drawable.id); - - /* Bail out if the Windows window handle is invalid */ - if (pWinPriv->hWnd == NULL) - return; - - winInDestroyWindowsWindow = TRUE; - - /* Store the info we need to destroy after this window is gone */ - hIcon = (HICON) SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_BIG, 0); - hIconSm = (HICON) SendMessage(pWinPriv->hWnd, WM_GETICON, ICON_SMALL, 0); - - /* Destroy the Windows window */ - DestroyWindow(pWinPriv->hWnd); - - /* Null our handle to the Window so referencing it will cause an error */ - pWinPriv->hWnd = NULL; - - /* Destroy any icons we created for this window */ - winDestroyIcon(hIcon); - winDestroyIcon(hIconSm); - -#ifdef XWIN_GLX_WINDOWS - /* No longer note WGL used on this window */ - pWinPriv->fWglUsed = FALSE; -#endif - - /* Process all messages on our queue */ - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if (g_hDlgDepthChange == 0 || !IsDialogMessage(g_hDlgDepthChange, &msg)) { - DispatchMessage(&msg); - } - } - - winInDestroyWindowsWindow = oldstate; - - winDebug("winDestroyWindowsWindow - done\n"); -} - -/* - * winUpdateWindowsWindow - Redisplay/redraw a Windows window - * associated with an X window - */ - -static void -winUpdateWindowsWindow(WindowPtr pWin) -{ - winWindowPriv(pWin); - HWND hWnd = pWinPriv->hWnd; - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winUpdateWindowsWindow\n"); -#endif - - /* Check if the Windows window's parents have been destroyed */ - if (pWin->parent != NULL && pWin->parent->parent == NULL && pWin->mapped) { - /* Create the Windows window if it has been destroyed */ - if (hWnd == NULL) { - winCreateWindowsWindow(pWin); - assert(pWinPriv->hWnd != NULL); - } - - /* Display the window without activating it */ - if (pWin->drawable.class != InputOnly) - ShowWindow(pWinPriv->hWnd, SW_SHOWNOACTIVATE); - - /* Send first paint message */ - UpdateWindow(pWinPriv->hWnd); - } - else if (hWnd != NULL) { - /* Destroy the Windows window if its parents are destroyed */ - winDestroyWindowsWindow(pWin); - assert(pWinPriv->hWnd == NULL); - } - -#if CYGMULTIWINDOW_DEBUG - ErrorF("-winUpdateWindowsWindow\n"); -#endif -} - -/* - * winGetWindowID - - */ - -XID -winGetWindowID(WindowPtr pWin) -{ - WindowIDPairRec wi = { pWin, 0 }; - ClientPtr c = wClient(pWin); - - /* */ - FindClientResourcesByType(c, RT_WINDOW, winFindWindow, &wi); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winGetWindowID - Window ID: %u\n", (unsigned int)wi.id); -#endif - - return wi.id; -} - -/* - * winFindWindow - - */ - -static void -winFindWindow(void *value, XID id, void *cdata) -{ - WindowIDPairPtr wi = (WindowIDPairPtr) cdata; - - if (value == wi->value) { - wi->id = id; - } -} - -/* - * winReorderWindowsMultiWindow - - */ - -void -winReorderWindowsMultiWindow(void) -{ - HWND hwnd = NULL; - WindowPtr pWin = NULL; - WindowPtr pWinSib = NULL; - XID vlist[2]; - static Bool fRestacking = FALSE; /* Avoid recursive calls to this function */ - DWORD dwCurrentProcessID = GetCurrentProcessId(); - DWORD dwWindowProcessID = 0; - -#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG - winTrace("winReorderWindowsMultiWindow\n"); -#endif - - if (fRestacking) { - /* It is a recursive call so immediately exit */ -#if CYGWINDOWING_DEBUG - ErrorF("winReorderWindowsMultiWindow - " - "exit because fRestacking == TRUE\n"); -#endif - return; - } - fRestacking = TRUE; - - /* Loop through top level Window windows, descending in Z order */ - for (hwnd = GetTopWindow(NULL); - hwnd; hwnd = GetNextWindow(hwnd, GW_HWNDNEXT)) { - /* Don't take care of other Cygwin/X process's windows */ - GetWindowThreadProcessId(hwnd, &dwWindowProcessID); - - if (GetProp(hwnd, WIN_WINDOW_PROP) - && (dwWindowProcessID == dwCurrentProcessID) - && !IsIconic(hwnd)) { /* ignore minimized windows */ - pWinSib = pWin; - pWin = GetProp(hwnd, WIN_WINDOW_PROP); - - if (!pWinSib) { /* 1st window - raise to the top */ - vlist[0] = Above; - - ConfigureWindow(pWin, CWStackMode, vlist, wClient(pWin)); - } - else { /* 2nd or deeper windows - just below the previous one */ - vlist[0] = winGetWindowID(pWinSib); - vlist[1] = Below; - - ConfigureWindow(pWin, CWSibling | CWStackMode, - vlist, wClient(pWin)); - } - } - } - - fRestacking = FALSE; -} - -/* - * CopyWindow - See Porting Layer Definition - p. 39 - */ -void -winCopyWindowMultiWindow(WindowPtr pWin, DDXPointRec oldpt, RegionPtr oldRegion) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGWINDOWING_DEBUG - ErrorF("CopyWindowMultiWindow\n"); -#endif - WIN_UNWRAP(CopyWindow); - (*pScreen->CopyWindow) (pWin, oldpt, oldRegion); - WIN_WRAP(CopyWindow, winCopyWindowMultiWindow); -} - -/* - * MoveWindow - See Porting Layer Definition - p. 42 - */ -void -winMoveWindowMultiWindow(WindowPtr pWin, int x, int y, - WindowPtr pSib, VTKind kind) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGWINDOWING_DEBUG - ErrorF("MoveWindowMultiWindow to (%d, %d)\n", x, y); -#endif - - WIN_UNWRAP(MoveWindow); - (*pScreen->MoveWindow) (pWin, x, y, pSib, kind); - WIN_WRAP(MoveWindow, winMoveWindowMultiWindow); -} - -/* - * ResizeWindow - See Porting Layer Definition - p. 42 - */ -void -winResizeWindowMultiWindow(WindowPtr pWin, int x, int y, unsigned int w, - unsigned int h, WindowPtr pSib) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGWINDOWING_DEBUG - ErrorF("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h); -#endif - WIN_UNWRAP(ResizeWindow); - (*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib); - WIN_WRAP(ResizeWindow, winResizeWindowMultiWindow); -} - -/* - * winAdjustXWindow - * - * Move and resize X window with respect to corresponding Windows window. - * This is called from WM_MOVE/WM_SIZE handlers when the user performs - * any windowing operation (move, resize, minimize, maximize, restore). - * - * The functionality is the inverse of winPositionWindowMultiWindow, which - * adjusts Windows window with respect to X window. - */ -int -winAdjustXWindow(WindowPtr pWin, HWND hwnd) -{ - RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */ - RECT rcWin; /* The source: WindowRect from hwnd */ - DrawablePtr pDraw; - XID vlist[4]; - LONG dX, dY, dW, dH, x, y; - DWORD dwStyle, dwExStyle; - -#define WIDTH(rc) (rc.right - rc.left) -#define HEIGHT(rc) (rc.bottom - rc.top) - -#if CYGWINDOWING_DEBUG - ErrorF("winAdjustXWindow\n"); -#endif - - if (IsIconic(hwnd)) { -#if CYGWINDOWING_DEBUG - ErrorF("\timmediately return because the window is iconized\n"); -#endif - /* - * 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); -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tDrawable extend {%d, %d, %d, %d}, {%d, %d}\n", - (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom, - (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top)); -#endif - dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tWindowStyle: %08x %08x\n", (unsigned int)dwStyle, (unsigned int)dwExStyle); -#endif - AdjustWindowRectEx(&rcDraw, dwStyle, FALSE, dwExStyle); - - /* The source of adjust */ - GetWindowRect(hwnd, &rcWin); -#ifdef CYGMULTIWINDOW_DEBUG - winDebug("\tWindow extend {%d, %d, %d, %d}, {%d, %d}\n", - (int)rcWin.left, (int)rcWin.top, (int)rcWin.right, (int)rcWin.bottom, - (int)(rcWin.right - rcWin.left), (int)(rcWin.bottom - rcWin.top)); - winDebug("\tDraw extend {%d, %d, %d, %d}, {%d, %d}\n", - (int)rcDraw.left, (int)rcDraw.top, (int)rcDraw.right, (int)rcDraw.bottom, - (int)(rcDraw.right - rcDraw.left), (int)(rcDraw.bottom - rcDraw.top)); -#endif - - if (EqualRect(&rcDraw, &rcWin)) { - /* Bail if no adjust is needed */ -#if CYGWINDOWING_DEBUG - ErrorF("\treturn because already adjusted\n"); -#endif - 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; -#if CYGWINDOWING_DEBUG - ErrorF("\tConfigureWindow to (%u, %u) - %ux%u\n", - (unsigned int)vlist[0], (unsigned int)vlist[1], - (unsigned int)vlist[2], (unsigned int)vlist[3]); -#endif - return ConfigureWindow(pWin, CWX | CWY | CWWidth | CWHeight, - vlist, wClient(pWin)); - -#undef WIDTH -#undef HEIGHT -} - -/* - Helper function for creating a DIB to back a pixmap - */ -static HBITMAP winCreateDIB(ScreenPtr pScreen, int width, int height, int bpp, void **ppvBits, BITMAPINFOHEADER **ppbmih) -{ - winScreenPriv(pScreen); - BITMAPV4HEADER *pbmih = NULL; - HBITMAP hBitmap = NULL; - - /* Allocate bitmap info header */ - pbmih = malloc(sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD)); - if (pbmih == NULL) { - ErrorF("winCreateDIB: malloc() failed\n"); - return NULL; - } - memset(pbmih, 0, sizeof(BITMAPV4HEADER) + 256 * sizeof(RGBQUAD)); - - /* Describe bitmap to be created */ - pbmih->bV4Size = sizeof(BITMAPV4HEADER); - pbmih->bV4Width = width; - pbmih->bV4Height = -height; /* top-down bitmap */ - pbmih->bV4Planes = 1; - pbmih->bV4BitCount = bpp; - if (bpp == 1) { - RGBQUAD *bmiColors = (RGBQUAD *)((char *)pbmih + sizeof(BITMAPV4HEADER)); - pbmih->bV4V4Compression = BI_RGB; - bmiColors[1].rgbBlue = 255; - bmiColors[1].rgbGreen = 255; - bmiColors[1].rgbRed = 255; - } - else if (bpp == 8) { - pbmih->bV4V4Compression = BI_RGB; - pbmih->bV4ClrUsed = 0; - } - else if (bpp == 16) { - pbmih->bV4V4Compression = BI_RGB; - pbmih->bV4ClrUsed = 0; - } - else if (bpp == 32) { - pbmih->bV4V4Compression = BI_BITFIELDS; - pbmih->bV4RedMask = pScreenPriv->dwRedMask; - pbmih->bV4GreenMask = pScreenPriv->dwGreenMask; - pbmih->bV4BlueMask = pScreenPriv->dwBlueMask; - pbmih->bV4AlphaMask = 0; - } - else { - ErrorF("winCreateDIB: %d bpp unhandled\n", bpp); - } - - /* Create a DIB with a bit pointer */ - hBitmap = CreateDIBSection(NULL, - (BITMAPINFO *) pbmih, - DIB_RGB_COLORS, ppvBits, NULL, 0); - if (hBitmap == NULL) { - ErrorF("winCreateDIB: CreateDIBSection() failed\n"); - return NULL; - } - - /* Store the address of the BMIH in the ppbmih parameter */ - *ppbmih = (BITMAPINFOHEADER *)pbmih; - - winDebug("winCreateDIB: HBITMAP %p pBMIH %p pBits %p\n", hBitmap, pbmih, *ppvBits); - - return hBitmap; -} - - -/* - * CreatePixmap - See Porting Layer Definition - */ -PixmapPtr -winCreatePixmapMultiwindow(ScreenPtr pScreen, int width, int height, int depth, - unsigned usage_hint) -{ - winPrivPixmapPtr pPixmapPriv = NULL; - PixmapPtr pPixmap = NULL; - int bpp, paddedwidth; - - /* allocate Pixmap header and privates */ - pPixmap = AllocatePixmap(pScreen, 0); - if (!pPixmap) - return NullPixmap; - - bpp = BitsPerPixel(depth); - /* - DIBs have 4-byte aligned rows - - paddedwidth is the width in bytes, padded to align - - i.e. round up the number of bits used by a row so it is a multiple of 32, - then convert to bytes - */ - paddedwidth = (((bpp * width) + 31) & ~31)/8; - - /* setup Pixmap header */ - pPixmap->drawable.type = DRAWABLE_PIXMAP; - pPixmap->drawable.class = 0; - pPixmap->drawable.pScreen = pScreen; - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = bpp; - pPixmap->drawable.id = 0; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - pPixmap->drawable.x = 0; - pPixmap->drawable.y = 0; - pPixmap->drawable.width = width; - pPixmap->drawable.height = height; - pPixmap->devKind = paddedwidth; - pPixmap->refcnt = 1; - pPixmap->devPrivate.ptr = NULL; // later set to pbBits - pPixmap->primary_pixmap = NULL; -#ifdef COMPOSITE - pPixmap->screen_x = 0; - pPixmap->screen_y = 0; -#endif - pPixmap->usage_hint = usage_hint; - - /* Check for zero width or height pixmaps */ - if (width == 0 || height == 0) { - /* DIBs with a dimension of 0 aren't permitted, so don't try to allocate - a DIB, just set fields and return */ - return pPixmap; - } - - /* Initialize pixmap privates */ - pPixmapPriv = winGetPixmapPriv(pPixmap); - pPixmapPriv->hBitmap = NULL; - pPixmapPriv->pbBits = NULL; - pPixmapPriv->pbmih = NULL; - - /* Create a DIB for the pixmap */ - pPixmapPriv->hBitmap = winCreateDIB(pScreen, width, height, bpp, &pPixmapPriv->pbBits, &pPixmapPriv->pbmih); - pPixmapPriv->owned = TRUE; - - winDebug("winCreatePixmap: pPixmap %p HBITMAP %p pBMIH %p pBits %p\n", pPixmap, pPixmapPriv->hBitmap, pPixmapPriv->pbmih, pPixmapPriv->pbBits); - /* XXX: so why do we need this in privates ??? */ - pPixmap->devPrivate.ptr = pPixmapPriv->pbBits; - - return pPixmap; -} - -/* - * DestroyPixmap - See Porting Layer Definition - */ -Bool -winDestroyPixmapMultiwindow(PixmapPtr pPixmap) -{ - winPrivPixmapPtr pPixmapPriv = NULL; - - /* Bail early if there is not a pixmap to destroy */ - if (pPixmap == NULL) { - return TRUE; - } - - /* Decrement reference count, return if nonzero */ - --pPixmap->refcnt; - if (pPixmap->refcnt != 0) - return TRUE; - - winDebug("winDestroyPixmap: pPixmap %p\n", pPixmap); - - /* Get a handle to the pixmap privates */ - pPixmapPriv = winGetPixmapPriv(pPixmap); - - /* Nothing to do if we don't own the DIB */ - if (!pPixmapPriv->owned) - 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; -} - -/* - * ModifyPixmapHeader - See Porting Layer Definition - */ -Bool -winModifyPixmapHeaderMultiwindow(PixmapPtr pPixmap, - int width, - int height, - int depth, - int bitsPerPixel, int devKind, void *pPixData) -{ - int i; - winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap); - Bool fResult; - - /* reinitialize everything */ - pPixmap->drawable.depth = depth; - pPixmap->drawable.bitsPerPixel = bitsPerPixel; - pPixmap->drawable.id = 0; - pPixmap->drawable.x = 0; - pPixmap->drawable.y = 0; - pPixmap->drawable.width = width; - pPixmap->drawable.height = height; - pPixmap->devKind = devKind; - pPixmap->refcnt = 1; - pPixmap->devPrivate.ptr = pPixData; - pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; - - /* - This can be used for some out-of-order initialization on the screen - pixmap, which is the only case we can properly support. - */ - - /* Look for which screen this pixmap corresponds to */ - for (i = 0; i < screenInfo.numScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - if (pScreenInfo->pfb == pPixData) - { - /* and initialize pixmap privates from screen privates */ - pPixmapPriv->hBitmap = pScreenPriv->hbmpShadow; - pPixmapPriv->pbBits = pScreenInfo->pfb; - pPixmapPriv->pbmih = pScreenPriv->pbmih; - - /* mark these not to get released by DestroyPixmap */ - pPixmapPriv->owned = FALSE; - - return TRUE; - } - } - - /* Otherwise, since creating a DIBSection from arbitrary memory is not - * possible, fallback to normal. If needed, we can create a DIBSection with - * a copy of the bits later (see comment about a potential slow-path in - * winBltExposedWindowRegionShadowGDI()). */ - pPixmapPriv->hBitmap = 0; - pPixmapPriv->pbBits = 0; - pPixmapPriv->pbmih = 0; - pPixmapPriv->owned = FALSE; - - winDebug("winModifyPixmapHeaderMultiwindow: falling back\n"); - - { - ScreenPtr pScreen = pPixmap->drawable.pScreen; - winScreenPriv(pScreen); - WIN_UNWRAP(ModifyPixmapHeader); - fResult = (*pScreen->ModifyPixmapHeader) (pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData); - WIN_WRAP(ModifyPixmapHeader, winModifyPixmapHeaderMultiwindow); - } - - return fResult; -} diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c deleted file mode 100644 index 37f1a7a02..000000000 --- a/hw/xwin/winmultiwindowwm.c +++ /dev/null @@ -1,2013 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - *Copyright (C) Colin Harrison 2005-2009 - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Colin Harrison - */ - -/* X headers */ -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#ifdef __CYGWIN__ -#include <sys/select.h> -#endif -#include <fcntl.h> -#include <setjmp.h> -#define HANDLE void * -#include <pthread.h> -#undef HANDLE -#include <xcb/xcb.h> -#include <xcb/xcb_icccm.h> -#include <xcb/xcb_ewmh.h> -#include <xcb/xcb_aux.h> -#include <xcb/composite.h> - -#include <X11/Xwindows.h> - -/* Local headers */ -#include "X11/Xdefs.h" // for Bool type -#include "winwindow.h" -#include "winprefs.h" -#include "window.h" -#include "pixmapstr.h" -#include "windowstr.h" -#include "winglobals.h" -#include "windisplay.h" -#include "winmultiwindowicons.h" -#include "winauth.h" - -/* We need the native HWND atom for intWM, so for consistency use the - same name as extWM does */ -#define WINDOWSWM_NATIVE_HWND "_WINDOWSWM_NATIVE_HWND" - -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif - -extern void winDebug(const char *format, ...); -extern void winReshapeMultiWindow(WindowPtr pWin); -extern void winUpdateRgnMultiWindow(WindowPtr pWin); - -#ifndef CYGDEBUG -#define CYGDEBUG NO -#endif - -/* - * Constant defines - */ - -#define WIN_CONNECT_RETRIES 5 -#define WIN_CONNECT_DELAY 5 -#ifdef HAS_DEVWINDOWS -#define WIN_MSG_QUEUE_FNAME "/dev/windows" -#endif - -/* - * Local structures - */ - -typedef struct _WMMsgNodeRec { - winWMMessageRec msg; - struct _WMMsgNodeRec *pNext; -} WMMsgNodeRec, *WMMsgNodePtr; - -typedef struct _WMMsgQueueRec { - struct _WMMsgNodeRec *pHead; - struct _WMMsgNodeRec *pTail; - pthread_mutex_t pmMutex; - pthread_cond_t pcNotEmpty; -} WMMsgQueueRec, *WMMsgQueuePtr; - -typedef struct _WMInfo { - xcb_connection_t *conn; - WMMsgQueueRec wmMsgQueue; - xcb_atom_t atmWmProtos; - xcb_atom_t atmWmDelete; - xcb_atom_t atmWmTakeFocus; - xcb_atom_t atmPrivMap; - xcb_atom_t atmUtf8String; - xcb_atom_t atmNetWmName; - xcb_atom_t atmCurrentDesktop; - xcb_atom_t atmNumberDesktops; - xcb_atom_t atmDesktopNames; - xcb_ewmh_connection_t ewmh; - Bool fCompositeWM; -} WMInfoRec, *WMInfoPtr; - -typedef struct _WMProcArgRec { - DWORD dwScreen; - WMInfoPtr pWMInfo; - pthread_mutex_t *ppmServerStarted; -} WMProcArgRec, *WMProcArgPtr; - -typedef struct _XMsgProcArgRec { - xcb_connection_t *conn; - DWORD dwScreen; - WMInfoPtr pWMInfo; - pthread_mutex_t *ppmServerStarted; - HWND hwndScreen; -} XMsgProcArgRec, *XMsgProcArgPtr; - -/* - * Prototypes for local functions - */ - -static void - PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode); - -static WMMsgNodePtr PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo); - -static Bool - InitQueue(WMMsgQueuePtr pQueue); - -static void - GetWindowName(WMInfoPtr pWMInfo, xcb_window_t iWin, char **ppWindowName); - -static void - SendXMessage(xcb_connection_t *conn, xcb_window_t iWin, xcb_atom_t atmType, long nData); - -static void - UpdateName(WMInfoPtr pWMInfo, xcb_window_t iWindow); - -static void *winMultiWindowWMProc(void *pArg); - -static void *winMultiWindowXMsgProc(void *pArg); - -static void - winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg); - -#if 0 -static void - PreserveWin32Stack(WMInfoPtr pWMInfo, xcb_window_t iWindow, UINT direction); -#endif - -static Bool -CheckAnotherWindowManager(xcb_connection_t *conn, DWORD dwScreen); - -static void - winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle); - -void - winUpdateWindowPosition(HWND hWnd, HWND * zstyle); - -/* - * Local globals - */ - -static Bool g_shutdown = FALSE; - -/* - * Translate msg id to text, for debug purposes - */ - -#if CYGMULTIWINDOW_DEBUG -static const char * -MessageName(winWMMessagePtr msg) -{ - switch (msg->msg) - { - case WM_WM_MOVE: - return "WM_WM_MOVE"; - break; - case WM_WM_SIZE: - return "WM_WM_SIZE"; - break; - case WM_WM_RAISE: - return "WM_WM_RAISE"; - break; - case WM_WM_LOWER: - return "WM_WM_LOWER"; - break; - case WM_WM_UNMAP: - return "WM_WM_UNMAP"; - break; - case WM_WM_KILL: - return "WM_WM_KILL"; - break; - case WM_WM_ACTIVATE: - return "WM_WM_ACTIVATE"; - break; - case WM_WM_NAME_EVENT: - return "WM_WM_NAME_EVENT"; - break; - case WM_WM_ICON_EVENT: - return "WM_WM_ICON_EVENT"; - break; - case WM_WM_CHANGE_STATE: - return "WM_WM_CHANGE_STATE"; - break; - case WM_WM_MAP_UNMANAGED: - return "WM_WM_MAP_UNMANAGED"; - break; - case WM_WM_MAP_MANAGED: - return "WM_WM_MAP_MANAGED"; - break; - case WM_WM_HINTS_EVENT: - return "WM_WM_HINTS_EVENT"; - break; - default: - return "Unknown Message"; - break; - } -} -#endif - - -/* - * PushMessage - Push a message onto the queue - */ - -static void -PushMessage(WMMsgQueuePtr pQueue, WMMsgNodePtr pNode) -{ - - /* Lock the queue mutex */ - pthread_mutex_lock(&pQueue->pmMutex); - - pNode->pNext = NULL; - - if (pQueue->pTail != NULL) { - pQueue->pTail->pNext = pNode; - } - pQueue->pTail = pNode; - - if (pQueue->pHead == NULL) { - pQueue->pHead = pNode; - } - - /* Release the queue mutex */ - pthread_mutex_unlock(&pQueue->pmMutex); - - /* Signal that the queue is not empty */ - pthread_cond_signal(&pQueue->pcNotEmpty); -} - -/* - * PopMessage - Pop a message from the queue - */ - -static WMMsgNodePtr -PopMessage(WMMsgQueuePtr pQueue, WMInfoPtr pWMInfo) -{ - WMMsgNodePtr pNode; - - /* Lock the queue mutex */ - pthread_mutex_lock(&pQueue->pmMutex); - - /* Wait for --- */ - while (pQueue->pHead == NULL) { - pthread_cond_wait(&pQueue->pcNotEmpty, &pQueue->pmMutex); - } - - pNode = pQueue->pHead; - if (pQueue->pHead != NULL) { - pQueue->pHead = pQueue->pHead->pNext; - } - - if (pQueue->pTail == pNode) { - pQueue->pTail = NULL; - } - - /* Release the queue mutex */ - pthread_mutex_unlock(&pQueue->pmMutex); - - return pNode; -} - -#if 0 -/* - * HaveMessage - - */ - -static Bool -HaveMessage(WMMsgQueuePtr pQueue, UINT msg, xcb_window_t iWindow) -{ - WMMsgNodePtr pNode; - - for (pNode = pQueue->pHead; pNode != NULL; pNode = pNode->pNext) { - if (pNode->msg.msg == msg && pNode->msg.iWindow == iWindow) - return True; - } - - return False; -} -#endif - -/* - * InitQueue - Initialize the Window Manager message queue - */ - -static - Bool -InitQueue(WMMsgQueuePtr pQueue) -{ - /* Check if the pQueue pointer is NULL */ - if (pQueue == NULL) { - ErrorF("InitQueue - pQueue is NULL. Exiting.\n"); - return FALSE; - } - - /* Set the head and tail to NULL */ - pQueue->pHead = NULL; - pQueue->pTail = NULL; - - winDebug("InitQueue - Calling pthread_mutex_init\n"); - - /* Create synchronization objects */ - pthread_mutex_init(&pQueue->pmMutex, NULL); - - winDebug("InitQueue - pthread_mutex_init returned\n"); - winDebug("InitQueue - Calling pthread_cond_init\n"); - - pthread_cond_init(&pQueue->pcNotEmpty, NULL); - - winDebug("InitQueue - pthread_cond_init returned\n"); - - return TRUE; -} - -static -char * -Xutf8TextPropertyToString(WMInfoPtr pWMInfo, xcb_icccm_get_text_property_reply_t *xtp) -{ - char *pszReturnData; - - if ((xtp->encoding == XCB_ATOM_STRING) || // Latin1 ISO 8859-1 - (xtp->encoding == pWMInfo->atmUtf8String)) { // UTF-8 ISO 10646 - pszReturnData = strndup(xtp->name, xtp->name_len); - } - else { - // Converting from COMPOUND_TEXT to UTF-8 properly is complex to - // implement, and not very much use unless you have an old - // application which isn't UTF-8 aware. - ErrorF("Xutf8TextPropertyToString: text encoding %d is not implemented\n", xtp->encoding); - pszReturnData = strdup(""); - } - - return pszReturnData; -} - -/* - * GetWindowName - Retrieve the title of an X Window - */ - -static void -GetWindowName(WMInfoPtr pWMInfo, xcb_window_t iWin, char **ppWindowName) -{ - xcb_connection_t *conn = pWMInfo->conn; - char *pszWindowName = NULL; - -#if CYGMULTIWINDOW_DEBUG - ErrorF("GetWindowName\n"); -#endif - - /* Try to get window name from _NET_WM_NAME */ - { - xcb_get_property_cookie_t cookie; - xcb_get_property_reply_t *reply; - - cookie = xcb_get_property(pWMInfo->conn, FALSE, iWin, - pWMInfo->atmNetWmName, - XCB_GET_PROPERTY_TYPE_ANY, 0, INT_MAX); - reply = xcb_get_property_reply(pWMInfo->conn, cookie, NULL); - if (reply && (reply->type != XCB_NONE)) { - pszWindowName = strndup(xcb_get_property_value(reply), - xcb_get_property_value_length(reply)); - free(reply); - } - } - - /* Otherwise, try to get window name from WM_NAME */ - if (!pszWindowName) - { - xcb_get_property_cookie_t cookie; - xcb_icccm_get_text_property_reply_t reply; - - cookie = xcb_icccm_get_wm_name(conn, iWin); - if (!xcb_icccm_get_wm_name_reply(conn, cookie, &reply, NULL)) { - ErrorF("GetWindowName - xcb_icccm_get_wm_name_reply failed. No name.\n"); - *ppWindowName = NULL; - return; - } - - pszWindowName = Xutf8TextPropertyToString(pWMInfo, &reply); - xcb_icccm_get_text_property_reply_wipe(&reply); - } - - /* return the window name, unless... */ - *ppWindowName = pszWindowName; - - if (g_fHostInTitle) { - xcb_get_property_cookie_t cookie; - xcb_icccm_get_text_property_reply_t reply; - - /* Try to get client machine name */ - cookie = xcb_icccm_get_wm_client_machine(conn, iWin); - if (xcb_icccm_get_wm_client_machine_reply(conn, cookie, &reply, NULL)) { - char *pszClientMachine; - char *pszClientHostname; - char *dot; - char hostname[HOST_NAME_MAX + 1]; - - pszClientMachine = Xutf8TextPropertyToString(pWMInfo, &reply); - xcb_icccm_get_text_property_reply_wipe(&reply); - - /* If client machine name looks like a FQDN, find the hostname */ - pszClientHostname = strdup(pszClientMachine); - dot = strchr(pszClientHostname, '.'); - if (dot) - *dot = '\0'; - - /* - If we have a client machine hostname - and it's not the local hostname - and it's not already in the window title... - */ - if (strlen(pszClientHostname) && - !gethostname(hostname, HOST_NAME_MAX + 1) && - strcmp(hostname, pszClientHostname) && - (strstr(pszWindowName, pszClientHostname) == 0)) { - /* ... add '@<clientmachine>' to end of window name */ - *ppWindowName = - malloc(strlen(pszWindowName) + - strlen(pszClientMachine) + 2); - strcpy(*ppWindowName, pszWindowName); - strcat(*ppWindowName, "@"); - strcat(*ppWindowName, pszClientMachine); - - free(pszWindowName); - } - - free(pszClientMachine); - free(pszClientHostname); - } - } -} - -/* - * Does the client support the specified WM_PROTOCOLS protocol? - */ - -static Bool -IsWmProtocolAvailable(WMInfoPtr pWMInfo, xcb_window_t iWindow, xcb_atom_t atmProtocol) -{ - int i, found = 0; - xcb_get_property_cookie_t cookie; - xcb_icccm_get_wm_protocols_reply_t reply; - xcb_connection_t *conn = pWMInfo->conn; - - cookie = xcb_icccm_get_wm_protocols(conn, iWindow, pWMInfo->ewmh.WM_PROTOCOLS); - if (xcb_icccm_get_wm_protocols_reply(conn, cookie, &reply, NULL)) { - for (i = 0; i < reply.atoms_len; ++i) - if (reply.atoms[i] == atmProtocol) { - ++found; - break; - } - xcb_icccm_get_wm_protocols_reply_wipe(&reply); - } - - return found > 0; -} - -/* - * Send a message to the X server from the WM thread - */ - -static void -SendXMessage(xcb_connection_t *conn, xcb_window_t iWin, xcb_atom_t atmType, long nData) -{ - xcb_client_message_event_t e; - - /* Prepare the X event structure */ - memset(&e, 0, sizeof(e)); - e.response_type = XCB_CLIENT_MESSAGE; - e.window = iWin; - e.type = atmType; - e.format = 32; - e.data.data32[0] = nData; - e.data.data32[1] = XCB_CURRENT_TIME; - - /* Send the event to X */ - xcb_send_event(conn, FALSE, iWin, XCB_EVENT_MASK_NO_EVENT, (const char *)&e); -} - -/* - * See if we can get the stored HWND for this window... - */ -static HWND -getHwnd(WMInfoPtr pWMInfo, xcb_window_t iWindow) -{ - HWND hWnd = NULL; - xcb_get_property_cookie_t cookie; - xcb_get_property_reply_t *reply; - - cookie = xcb_get_property(pWMInfo->conn, FALSE, iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 0L, sizeof(HWND)/4L); - reply = xcb_get_property_reply(pWMInfo->conn, cookie, NULL); - - if (reply) { - int length = xcb_get_property_value_length(reply); - HWND *value = xcb_get_property_value(reply); - - if (value && (length == sizeof(HWND))) { - hWnd = *value; - } - free(reply); - } - - /* Some sanity checks */ - if (!hWnd) - return NULL; - if (!IsWindow(hWnd)) - return NULL; - - return hWnd; -} - -/* - * Helper function to check for override-redirect - */ -static Bool -IsOverrideRedirect(xcb_connection_t *conn, xcb_window_t iWin) -{ - Bool result = FALSE; - xcb_get_window_attributes_reply_t *reply; - xcb_get_window_attributes_cookie_t cookie; - - cookie = xcb_get_window_attributes(conn, iWin); - reply = xcb_get_window_attributes_reply(conn, cookie, NULL); - if (reply) { - result = (reply->override_redirect != 0); - free(reply); - } - else { - ErrorF("IsOverrideRedirect: Failed to get window attributes\n"); - } - - return result; -} - -/* - * Helper function to get class and window names -*/ -static void -GetClassNames(WMInfoPtr pWMInfo, xcb_window_t iWindow, char **res_name, - char **res_class, char **window_name) -{ - xcb_get_property_cookie_t cookie1; - xcb_icccm_get_wm_class_reply_t reply1; - xcb_get_property_cookie_t cookie2; - xcb_icccm_get_text_property_reply_t reply2; - - cookie1 = xcb_icccm_get_wm_class(pWMInfo->conn, iWindow); - if (xcb_icccm_get_wm_class_reply(pWMInfo->conn, cookie1, &reply1, - NULL)) { - *res_name = strdup(reply1.instance_name); - *res_class = strdup(reply1.class_name); - xcb_icccm_get_wm_class_reply_wipe(&reply1); - } - else { - *res_name = strdup(""); - *res_class = strdup(""); - } - - cookie2 = xcb_icccm_get_wm_name(pWMInfo->conn, iWindow); - if (xcb_icccm_get_wm_name_reply(pWMInfo->conn, cookie2, &reply2, NULL)) { - *window_name = strndup(reply2.name, reply2.name_len); - xcb_icccm_get_text_property_reply_wipe(&reply2); - } - else { - *window_name = strdup(""); - } -} - -/* - * Updates the name of a HWND according to its X WM_NAME property - */ - -static void -UpdateName(WMInfoPtr pWMInfo, xcb_window_t iWindow) -{ - HWND hWnd; - - hWnd = getHwnd(pWMInfo, iWindow); - if (!hWnd) - return; - - /* If window isn't override-redirect */ - if (!IsOverrideRedirect(pWMInfo->conn, iWindow)) { - char *pszWindowName; - - /* Get the X windows window name */ - GetWindowName(pWMInfo, iWindow, &pszWindowName); - - if (pszWindowName) { - /* Convert from UTF-8 to wide char */ - int iLen = - MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, NULL, 0); - wchar_t *pwszWideWindowName = - malloc(sizeof(wchar_t)*(iLen + 1)); - MultiByteToWideChar(CP_UTF8, 0, pszWindowName, -1, - pwszWideWindowName, iLen); - - /* Set the Windows window name */ - SetWindowTextW(hWnd, pwszWideWindowName); - - free(pwszWideWindowName); - free(pszWindowName); - } - } -} - -/* - * Updates the icon of a HWND according to its X icon properties - */ - -static void -UpdateIcon(WMInfoPtr pWMInfo, xcb_window_t iWindow) -{ - HWND hWnd; - HICON hIconNew = NULL; - - hWnd = getHwnd(pWMInfo, iWindow); - if (!hWnd) - return; - - /* If window isn't override-redirect */ - if (!IsOverrideRedirect(pWMInfo->conn, iWindow)) { - char *window_name = 0; - char *res_name = 0; - char *res_class = 0; - - GetClassNames(pWMInfo, iWindow, &res_name, &res_class, &window_name); - - hIconNew = winOverrideIcon(res_name, res_class, window_name); - - free(res_name); - free(res_class); - free(window_name); - winUpdateIcon(hWnd, pWMInfo->conn, iWindow, hIconNew); - } -} - -/* - * Updates the style of a HWND according to its X style properties - */ - -static void -UpdateStyle(WMInfoPtr pWMInfo, xcb_window_t iWindow) -{ - HWND hWnd; - HWND zstyle = HWND_NOTOPMOST; - UINT flags; - - hWnd = getHwnd(pWMInfo, iWindow); - if (!hWnd) - return; - - /* Determine the Window style, which determines borders and clipping region... */ - winApplyHints(pWMInfo, iWindow, hWnd, &zstyle); - winUpdateWindowPosition(hWnd, &zstyle); - - /* Apply the updated window style, without changing its show or activation state */ - flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE; - if (zstyle == HWND_NOTOPMOST) - flags |= SWP_NOZORDER | SWP_NOOWNERZORDER; - SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags); - - /* - Use the WS_EX_TOOLWINDOW style to remove window from Alt-Tab window switcher - - According to MSDN, this is supposed to remove the window from the taskbar as well, - if we SW_HIDE before changing the style followed by SW_SHOW afterwards. - - But that doesn't seem to work reliably, and causes the window to flicker, so use - the iTaskbarList interface to tell the taskbar to show or hide this window. - */ - winShowWindowOnTaskbar(hWnd, - (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & - WS_EX_APPWINDOW) ? TRUE : FALSE); -} - -/* - * Updates the state of a HWND - * (only minimization supported at the moment) - */ - -static void -UpdateState(WMInfoPtr pWMInfo, xcb_window_t iWindow) -{ - HWND hWnd; - - winDebug("UpdateState: iWindow 0x%08x\n", (int)iWindow); - - hWnd = getHwnd(pWMInfo, iWindow); - if (!hWnd) - return; - - ShowWindow(hWnd, SW_MINIMIZE); -} - -#if 0 -/* - * Fix up any differences between the X11 and Win32 window stacks - * starting at the window passed in - */ -static void -PreserveWin32Stack(WMInfoPtr pWMInfo, xcb_window_t iWindow, UINT direction) -{ - HWND hWnd; - DWORD myWinProcID, winProcID; - xcb_window_t xWindow; - WINDOWPLACEMENT wndPlace; - - hWnd = getHwnd(pWMInfo, iWindow); - if (!hWnd) - return; - - GetWindowThreadProcessId(hWnd, &myWinProcID); - hWnd = GetNextWindow(hWnd, direction); - - while (hWnd) { - GetWindowThreadProcessId(hWnd, &winProcID); - if (winProcID == myWinProcID) { - wndPlace.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement(hWnd, &wndPlace); - if (!(wndPlace.showCmd == SW_HIDE || - wndPlace.showCmd == SW_MINIMIZE)) { - xWindow = (Window) GetProp(hWnd, WIN_WID_PROP); - if (xWindow) { - if (direction == GW_HWNDPREV) - XRaiseWindow(pWMInfo->pDisplay, xWindow); - else - XLowerWindow(pWMInfo->pDisplay, xWindow); - } - } - } - hWnd = GetNextWindow(hWnd, direction); - } -} -#endif /* PreserveWin32Stack */ - -/* - * winMultiWindowWMProc - */ - -static void * -winMultiWindowWMProc(void *pArg) -{ - WMProcArgPtr pProcArg = (WMProcArgPtr) pArg; - WMInfoPtr pWMInfo = pProcArg->pWMInfo; - - /* Initialize the Window Manager */ - winInitMultiWindowWM(pWMInfo, pProcArg); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowWMProc ()\n"); -#endif - - /* Loop until we explicitly break out */ - for (;;) { - WMMsgNodePtr pNode; - - /* 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); - } - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winMultiWindowWMProc - MSG: %s (%d) ID: %d\n", - MessageName(&(pNode->msg)), (int)pNode->msg.msg, (int)pNode->msg.dwID); -#endif - - /* Branch on the message type */ - switch (pNode->msg.msg) { -#if 0 - case WM_WM_MOVE: - break; - - case WM_WM_SIZE: - break; -#endif - - case WM_WM_RAISE: - /* Raise the window */ - { - const static uint32_t values[] = { XCB_STACK_MODE_ABOVE }; - xcb_configure_window(pWMInfo->conn, pNode->msg.iWindow, - XCB_CONFIG_WINDOW_STACK_MODE, values); - } - -#if 0 - PreserveWin32Stack(pWMInfo, pNode->msg.iWindow, GW_HWNDPREV); -#endif - break; - - case WM_WM_LOWER: - /* Lower the window */ - { - const static uint32_t values[] = { XCB_STACK_MODE_BELOW }; - xcb_configure_window(pWMInfo->conn, pNode->msg.iWindow, - XCB_CONFIG_WINDOW_STACK_MODE, values); - } - break; - - case WM_WM_MAP_UNMANAGED: - /* Put a note as to the HWND associated with this Window */ - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, - pNode->msg.iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 32, - sizeof(HWND)/4, &(pNode->msg.hwndWindow)); - - break; - - case WM_WM_MAP_MANAGED: - /* Put a note as to the HWND associated with this Window */ - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, - pNode->msg.iWindow, pWMInfo->atmPrivMap, - XCB_ATOM_INTEGER, 32, - sizeof(HWND)/4, &(pNode->msg.hwndWindow)); - - UpdateName(pWMInfo, pNode->msg.iWindow); - UpdateIcon(pWMInfo, pNode->msg.iWindow); - UpdateStyle(pWMInfo, pNode->msg.iWindow); - - - /* Reshape */ - { - WindowPtr pWin = - GetProp(pNode->msg.hwndWindow, WIN_WINDOW_PROP); - if (pWin) { - winReshapeMultiWindow(pWin); - winUpdateRgnMultiWindow(pWin); - } - } - - break; - - case WM_WM_UNMAP: - - /* Unmap the window */ - xcb_unmap_window(pWMInfo->conn, pNode->msg.iWindow); - break; - - case WM_WM_KILL: - { - /* --- */ - if (IsWmProtocolAvailable(pWMInfo, - pNode->msg.iWindow, - pWMInfo->atmWmDelete)) - SendXMessage(pWMInfo->conn, - pNode->msg.iWindow, - pWMInfo->atmWmProtos, pWMInfo->atmWmDelete); - else - xcb_kill_client(pWMInfo->conn, pNode->msg.iWindow); - } - break; - - case WM_WM_ACTIVATE: - /* Set the input focus */ - - /* - ICCCM 4.1.7 is pretty opaque, but it appears that the rules are - actually quite simple: - -- the WM_HINTS input field determines whether the WM should call - XSetInputFocus() - -- independently, the WM_TAKE_FOCUS protocol determines whether - the WM should send a WM_TAKE_FOCUS ClientMessage. - */ - { - Bool neverFocus = FALSE; - xcb_get_property_cookie_t cookie; - xcb_icccm_wm_hints_t hints; - - cookie = xcb_icccm_get_wm_hints(pWMInfo->conn, pNode->msg.iWindow); - if (xcb_icccm_get_wm_hints_reply(pWMInfo->conn, cookie, &hints, - NULL)) { - if (hints.flags & XCB_ICCCM_WM_HINT_INPUT) - neverFocus = !hints.input; - } - - if (!neverFocus) - xcb_set_input_focus(pWMInfo->conn, XCB_INPUT_FOCUS_POINTER_ROOT, - pNode->msg.iWindow, XCB_CURRENT_TIME); - - if (IsWmProtocolAvailable(pWMInfo, - pNode->msg.iWindow, - pWMInfo->atmWmTakeFocus)) - SendXMessage(pWMInfo->conn, - pNode->msg.iWindow, - pWMInfo->atmWmProtos, pWMInfo->atmWmTakeFocus); - - } - break; - - case WM_WM_NAME_EVENT: - UpdateName(pWMInfo, pNode->msg.iWindow); - break; - - case WM_WM_ICON_EVENT: - UpdateIcon(pWMInfo, pNode->msg.iWindow); - break; - - case WM_WM_HINTS_EVENT: - { - /* Don't do anything if this is an override-redirect window */ - if (IsOverrideRedirect(pWMInfo->conn, pNode->msg.iWindow)) - break; - - UpdateStyle(pWMInfo, pNode->msg.iWindow); - } - break; - - case WM_WM_CHANGE_STATE: - UpdateState(pWMInfo, 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 */ - xcb_flush(pWMInfo->conn); - - /* This is just laziness rather than making sure we used _checked everywhere */ - { - xcb_generic_event_t *event = xcb_poll_for_event(pWMInfo->conn); - if (event) { - if ((event->response_type & ~0x80) == 0) { - xcb_generic_error_t *err = (xcb_generic_error_t *)event; - ErrorF("winMultiWindowWMProc - Error code: %i, ID: 0x%08x, " - "Major opcode: %i, Minor opcode: %i\n", - err->error_code, err->resource_id, - err->major_code, err->minor_code); - } - } - } - - /* I/O errors etc. */ - { - int e = xcb_connection_has_error(pWMInfo->conn); - if (e) { - ErrorF("winMultiWindowWMProc - Fatal error %d on xcb connection\n", e); - break; - } - } - } - - /* 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); - -#if CYGMULTIWINDOW_DEBUG - ErrorF("-winMultiWindowWMProc ()\n"); -#endif - return NULL; -} - -static xcb_atom_t -intern_atom(xcb_connection_t *conn, const char *atomName) -{ - xcb_intern_atom_reply_t *atom_reply; - xcb_intern_atom_cookie_t atom_cookie; - xcb_atom_t atom = XCB_ATOM_NONE; - - atom_cookie = xcb_intern_atom(conn, 0, strlen(atomName), atomName); - atom_reply = xcb_intern_atom_reply(conn, atom_cookie, NULL); - if (atom_reply) { - atom = atom_reply->atom; - free(atom_reply); - } - return atom; -} - -/* - * X message procedure - */ - -static void * -winMultiWindowXMsgProc(void *pArg) -{ - winWMMessageRec msg; - XMsgProcArgPtr pProcArg = (XMsgProcArgPtr) pArg; - char pszDisplay[512]; - int iRetries; - xcb_atom_t atmWmName; - xcb_atom_t atmNetWmName; - xcb_atom_t atmWmHints; - xcb_atom_t atmWmChange; - xcb_atom_t atmNetWmIcon; - xcb_atom_t atmWindowState, atmMotifWmHints, atmWindowType, atmNormalHints; - int iReturn; - xcb_auth_info_t *auth_info; - xcb_screen_t *root_screen; - xcb_window_t root_window_id; - - winDebug("winMultiWindowXMsgProc - Hello\n"); - - /* Check that argument pointer is not invalid */ - if (pProcArg == NULL) { - ErrorF("winMultiWindowXMsgProc - pProcArg is NULL. Exiting.\n"); - pthread_exit(NULL); - } - - winDebug("winMultiWindowXMsgProc - Calling pthread_mutex_lock ()\n"); - - /* Grab the server started mutex - pause until we get it */ - iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted); - if (iReturn != 0) { - ErrorF("winMultiWindowXMsgProc - pthread_mutex_lock () failed: %d. " - "Exiting.\n", iReturn); - pthread_exit(NULL); - } - - winDebug("winMultiWindowXMsgProc - pthread_mutex_lock () returned.\n"); - - /* Release the server started mutex */ - pthread_mutex_unlock(pProcArg->ppmServerStarted); - - winDebug("winMultiWindowXMsgProc - pthread_mutex_unlock () returned.\n"); - - /* Setup the display connection string x */ - winGetDisplayName(pszDisplay, (int) pProcArg->dwScreen); - - /* Print the display connection string */ - ErrorF("winMultiWindowXMsgProc - DISPLAY=%s\n", pszDisplay); - - /* Use our generated cookie for authentication */ - auth_info = winGetXcbAuthInfo(); - - /* Initialize retry count */ - iRetries = 0; - - /* Open the X display */ - do { - /* Try to open the display */ - pProcArg->conn = xcb_connect_to_display_with_auth_info(pszDisplay, - auth_info, NULL); - if (xcb_connection_has_error(pProcArg->conn)) { - ErrorF("winMultiWindowXMsgProc - Could not open display, try: %d, " - "sleeping: %d\n", iRetries + 1, WIN_CONNECT_DELAY); - ++iRetries; - sleep(WIN_CONNECT_DELAY); - continue; - } - else - break; - } - while (xcb_connection_has_error(pProcArg->conn) && iRetries < WIN_CONNECT_RETRIES); - - /* Make sure that the display opened */ - if (xcb_connection_has_error(pProcArg->conn)) { - ErrorF("winMultiWindowXMsgProc - Failed opening the display. " - "Exiting.\n"); - pthread_exit(NULL); - } - - ErrorF("winMultiWindowXMsgProc - xcb_connect() returned and " - "successfully opened the display.\n"); - - /* Check if another window manager is already running */ - if (CheckAnotherWindowManager(pProcArg->conn, pProcArg->dwScreen)) { - ErrorF("winMultiWindowXMsgProc - " - "another window manager is running. Exiting.\n"); - pthread_exit(NULL); - } - - /* Get root window id */ - root_screen = xcb_aux_get_screen(pProcArg->conn, pProcArg->dwScreen); - root_window_id = root_screen->root; - - { - /* Set WM_ICON_SIZE property indicating desired icon sizes */ - typedef struct { - uint32_t min_width, min_height; - uint32_t max_width, max_height; - int32_t width_inc, height_inc; - } xcb_wm_icon_size_hints_hints_t; - - xcb_wm_icon_size_hints_hints_t xis; - xis.min_width = xis.min_height = 16; - xis.max_width = xis.max_height = 48; - xis.width_inc = xis.height_inc = 16; - - xcb_change_property(pProcArg->conn, XCB_PROP_MODE_REPLACE, root_window_id, - XCB_ATOM_WM_ICON_SIZE, XCB_ATOM_WM_ICON_SIZE, 32, - sizeof(xis)/4, &xis); - } - - atmWmName = intern_atom(pProcArg->conn, "WM_NAME"); - atmNetWmName = intern_atom(pProcArg->conn, "_NET_WM_NAME"); - atmWmHints = intern_atom(pProcArg->conn, "WM_HINTS"); - atmWmChange = intern_atom(pProcArg->conn, "WM_CHANGE_STATE"); - atmNetWmIcon = intern_atom(pProcArg->conn, "_NET_WM_ICON"); - atmWindowState = intern_atom(pProcArg->conn, "_NET_WM_STATE"); - atmMotifWmHints = intern_atom(pProcArg->conn, "_MOTIF_WM_HINTS"); - atmWindowType = intern_atom(pProcArg->conn, "_NET_WM_WINDOW_TYPE"); - atmNormalHints = intern_atom(pProcArg->conn, "WM_NORMAL_HINTS"); - - /* - 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... - */ - intern_atom(pProcArg->conn, "WM_STATE"); - - /* - Enable Composite extension and redirect subwindows of the root window - */ - if (pProcArg->pWMInfo->fCompositeWM) { - const char *extension_name = "Composite"; - xcb_query_extension_cookie_t cookie; - xcb_query_extension_reply_t *reply; - - cookie = xcb_query_extension(pProcArg->conn, strlen(extension_name), extension_name); - reply = xcb_query_extension_reply(pProcArg->conn, cookie, NULL); - - if (reply && (reply->present)) { - xcb_composite_redirect_subwindows(pProcArg->conn, - root_window_id, - XCB_COMPOSITE_REDIRECT_AUTOMATIC); - - /* - We use automatic updating of the root window for two - reasons: - - 1) redirected window contents are mirrored to the root - window so that the root window draws correctly when shown. - - 2) updating the root window causes damage against the - shadow framebuffer, which ultimately causes WM_PAINT to be - sent to the affected window(s) to cause the damage regions - to be redrawn. - */ - - ErrorF("Using Composite redirection\n"); - - free(reply); - } - } - - /* Loop until we explicitly break out */ - while (1) { - xcb_generic_event_t *event; - uint8_t type; - Bool send_event; - - if (g_shutdown) - break; - - /* Fetch next event */ - event = xcb_wait_for_event(pProcArg->conn); - if (!event) { // returns NULL on I/O error - int e = xcb_connection_has_error(pProcArg->conn); - ErrorF("winMultiWindowXMsgProc - Fatal error %d on xcb connection\n", e); - break; - } - - type = event->response_type & ~0x80; - send_event = event->response_type & 0x80; - - winDebug("winMultiWindowXMsgProc - event %d\n", type); - - /* Branch on event type */ - if (type == 0) { - xcb_generic_error_t *err = (xcb_generic_error_t *)event; - ErrorF("winMultiWindowXMsgProc - Error code: %i, ID: 0x%08x, " - "Major opcode: %i, Minor opcode: %i\n", - err->error_code, err->resource_id, - err->major_code, err->minor_code); - } - else if (type == XCB_CREATE_NOTIFY) { - xcb_create_notify_event_t *notify = (xcb_create_notify_event_t *)event; - - /* Request property change events */ - const static uint32_t mask_value[] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; - xcb_change_window_attributes (pProcArg->conn, notify->window, - XCB_CW_EVENT_MASK, mask_value); - - /* If it's not override-redirect, set the border-width to 0 */ - if (!IsOverrideRedirect(pProcArg->conn, notify->window)) { - const static uint32_t width_value[] = { 0 }; - xcb_configure_window(pProcArg->conn, notify->window, - XCB_CONFIG_WINDOW_BORDER_WIDTH, width_value); - } - } - else if (type == XCB_MAP_NOTIFY) { - /* 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 - */ - - xcb_map_notify_event_t *notify = (xcb_map_notify_event_t *)event; - - xcb_get_geometry_cookie_t cookie; - xcb_get_geometry_reply_t *reply; - xcb_query_tree_cookie_t cookie_qt; - xcb_query_tree_reply_t *reply_qt; - - cookie = xcb_get_geometry(pProcArg->conn, notify->window); - cookie_qt = xcb_query_tree(pProcArg->conn, notify->window); - reply = xcb_get_geometry_reply(pProcArg->conn, cookie, NULL); - reply_qt = xcb_query_tree_reply(pProcArg->conn, cookie_qt, NULL); - - if (reply && reply_qt) { - /* - It's a top-level window if the parent window is a root window - Only non-override_redirect windows can get reparented - */ - if ((reply->root == reply_qt->parent) && !notify->override_redirect) { - xcb_reparent_notify_event_t event_send; - - event_send.response_type = XCB_REPARENT_NOTIFY; - event_send.event = notify->window; - event_send.window = notify->window; - event_send.parent = reply_qt->parent; - event_send.x = reply->x; - event_send.y = reply->y; - - xcb_send_event (pProcArg->conn, TRUE, notify->window, - XCB_EVENT_MASK_STRUCTURE_NOTIFY, - (const char *)&event_send); - - free(reply_qt); - free(reply); - } - } - } - else if (type == XCB_CONFIGURE_NOTIFY) { - if (!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 - */ - xcb_configure_notify_event_t *notify = (xcb_configure_notify_event_t *)event; - xcb_configure_notify_event_t event_send = *notify; - - event_send.event = notify->window; - - xcb_send_event(pProcArg->conn, TRUE, notify->window, - XCB_EVENT_MASK_STRUCTURE_NOTIFY, - (const char *)&event_send); - } - } - else if (type == XCB_PROPERTY_NOTIFY) { - xcb_property_notify_event_t *notify = (xcb_property_notify_event_t *)event; - - if ((notify->atom == atmWmName) || - (notify->atom == atmNetWmName)) { - memset(&msg, 0, sizeof(msg)); - - msg.msg = WM_WM_NAME_EVENT; - msg.iWindow = notify->window; - - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); - } - else { - /* - Several properties are considered for WM hints, check if this property change affects any of them... - (this list needs to be kept in sync with winApplyHints()) - */ - if ((notify->atom == atmWmHints) || - (notify->atom == atmWindowState) || - (notify->atom == atmMotifWmHints) || - (notify->atom == atmWindowType) || - (notify->atom == atmNormalHints)) { - memset(&msg, 0, sizeof(msg)); - msg.msg = WM_WM_HINTS_EVENT; - msg.iWindow = notify->window; - - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); - } - - /* Not an else as WM_HINTS affects both style and icon */ - if ((notify->atom == atmWmHints) || - (notify->atom == atmNetWmIcon)) { - memset(&msg, 0, sizeof(msg)); - msg.msg = WM_WM_ICON_EVENT; - msg.iWindow = notify->window; - - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); - } - } - } - else if (type == XCB_CLIENT_MESSAGE) { - xcb_client_message_event_t *client_msg = (xcb_client_message_event_t *)event; - - if (client_msg->type == atmWmChange - && client_msg->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC) { - ErrorF("winMultiWindowXMsgProc - WM_CHANGE_STATE - IconicState\n"); - - memset(&msg, 0, sizeof(msg)); - - msg.msg = WM_WM_CHANGE_STATE; - msg.iWindow = client_msg->window; - - winSendMessageToWM(pProcArg->pWMInfo, &msg); - } - } - - /* Free the event */ - free(event); - } - - xcb_disconnect(pProcArg->conn); - pthread_exit(NULL); - return NULL; -} - -/* - * winInitWM - Entry point for the X server to spawn - * the Window Manager thread. Called from - * winscrinit.c/winFinishScreenInitFB (). - */ - -Bool -winInitWM(void **ppWMInfo, - pthread_t * ptWMProc, - pthread_t * ptXMsgProc, - pthread_mutex_t * ppmServerStarted, - int dwScreen, HWND hwndScreen, Bool compositeWM) -{ - WMProcArgPtr pArg = malloc(sizeof(WMProcArgRec)); - WMInfoPtr pWMInfo = malloc(sizeof(WMInfoRec)); - XMsgProcArgPtr pXMsgArg = 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; - pWMInfo->fCompositeWM = compositeWM; - - /* Setup the argument structure for the thread function */ - pArg->dwScreen = dwScreen; - pArg->pWMInfo = pWMInfo; - pArg->ppmServerStarted = ppmServerStarted; - - /* Initialize the message queue */ - if (!InitQueue(&pWMInfo->wmMsgQueue)) { - ErrorF("winInitWM - InitQueue () failed.\n"); - return FALSE; - } - - /* Spawn a thread for the Window Manager */ - if (pthread_create(ptWMProc, NULL, winMultiWindowWMProc, pArg)) { - /* Bail if thread creation failed */ - ErrorF("winInitWM - pthread_create failed for Window Manager.\n"); - return FALSE; - } - - /* Spawn the XNextEvent thread, will send messages to WM */ - pXMsgArg->dwScreen = dwScreen; - pXMsgArg->pWMInfo = pWMInfo; - pXMsgArg->ppmServerStarted = ppmServerStarted; - pXMsgArg->hwndScreen = hwndScreen; - if (pthread_create(ptXMsgProc, NULL, winMultiWindowXMsgProc, pXMsgArg)) { - /* Bail if thread creation failed */ - ErrorF("winInitWM - pthread_create failed on XMSG.\n"); - return FALSE; - } - -#if CYGDEBUG || YES - winDebug("winInitWM - Returning.\n"); -#endif - - return TRUE; -} - -/* - * Window manager thread - setup - */ - -static void -winInitMultiWindowWM(WMInfoPtr pWMInfo, WMProcArgPtr pProcArg) -{ - int iRetries = 0; - char pszDisplay[512]; - int iReturn; - xcb_auth_info_t *auth_info; - xcb_screen_t *root_screen; - xcb_window_t root_window_id; - - winDebug("winInitMultiWindowWM - Hello\n"); - - /* Check that argument pointer is not invalid */ - if (pProcArg == NULL) { - ErrorF("winInitMultiWindowWM - pProcArg is NULL. Exiting.\n"); - pthread_exit(NULL); - } - - winDebug("winInitMultiWindowWM - Calling pthread_mutex_lock ()\n"); - - /* Grab our garbage mutex to satisfy pthread_cond_wait */ - iReturn = pthread_mutex_lock(pProcArg->ppmServerStarted); - if (iReturn != 0) { - ErrorF("winInitMultiWindowWM - pthread_mutex_lock () failed: %d. " - "Exiting.\n", iReturn); - pthread_exit(NULL); - } - - winDebug("winInitMultiWindowWM - pthread_mutex_lock () returned.\n"); - - /* Release the server started mutex */ - pthread_mutex_unlock(pProcArg->ppmServerStarted); - - winDebug("winInitMultiWindowWM - pthread_mutex_unlock () returned.\n"); - - /* Setup the display connection string x */ - winGetDisplayName(pszDisplay, (int) pProcArg->dwScreen); - - /* Print the display connection string */ - ErrorF("winInitMultiWindowWM - DISPLAY=%s\n", pszDisplay); - - /* Use our generated cookie for authentication */ - auth_info = winGetXcbAuthInfo(); - - /* Open the X display */ - do { - /* Try to open the display */ - pWMInfo->conn = xcb_connect_to_display_with_auth_info(pszDisplay, - auth_info, NULL); - if (xcb_connection_has_error(pWMInfo->conn)) { - 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 (xcb_connection_has_error(pWMInfo->conn) && iRetries < WIN_CONNECT_RETRIES); - - /* Make sure that the display opened */ - if (xcb_connection_has_error(pWMInfo->conn)) { - ErrorF("winInitMultiWindowWM - Failed opening the display. " - "Exiting.\n"); - pthread_exit(NULL); - } - - ErrorF("winInitMultiWindowWM - xcb_connect () returned and " - "successfully opened the display.\n"); - - /* Create some atoms */ - pWMInfo->atmWmProtos = intern_atom(pWMInfo->conn, "WM_PROTOCOLS"); - pWMInfo->atmWmDelete = intern_atom(pWMInfo->conn, "WM_DELETE_WINDOW"); - pWMInfo->atmWmTakeFocus = intern_atom(pWMInfo->conn, "WM_TAKE_FOCUS"); - pWMInfo->atmPrivMap = intern_atom(pWMInfo->conn, WINDOWSWM_NATIVE_HWND); - pWMInfo->atmUtf8String = intern_atom(pWMInfo->conn, "UTF8_STRING"); - pWMInfo->atmNetWmName = intern_atom(pWMInfo->conn, "_NET_WM_NAME"); - pWMInfo->atmCurrentDesktop = intern_atom(pWMInfo->conn, "_NET_CURRENT_DESKTOP"); - pWMInfo->atmNumberDesktops = intern_atom(pWMInfo->conn, "_NET_NUMBER_OF_DESKTOPS"); - pWMInfo->atmDesktopNames = intern_atom(pWMInfo->conn, "__NET_DESKTOP_NAMES"); - - /* Initialization for the xcb_ewmh and EWMH atoms */ - { - xcb_intern_atom_cookie_t *atoms_cookie; - atoms_cookie = xcb_ewmh_init_atoms(pWMInfo->conn, &pWMInfo->ewmh); - if (xcb_ewmh_init_atoms_replies(&pWMInfo->ewmh, atoms_cookie, NULL)) { - /* Set the _NET_SUPPORTED atom for this context. - - TODO: Audit to ensure we implement everything defined as MUSTs - for window managers in the EWMH standard.*/ - xcb_atom_t supported[] = - { - pWMInfo->ewmh.WM_PROTOCOLS, - pWMInfo->ewmh._NET_SUPPORTED, - pWMInfo->ewmh._NET_SUPPORTING_WM_CHECK, - pWMInfo->ewmh._NET_CLOSE_WINDOW, - pWMInfo->ewmh._NET_WM_WINDOW_TYPE, - pWMInfo->ewmh._NET_WM_WINDOW_TYPE_DOCK, - pWMInfo->ewmh._NET_WM_WINDOW_TYPE_SPLASH, - pWMInfo->ewmh._NET_WM_STATE, - pWMInfo->ewmh._NET_WM_STATE_HIDDEN, - pWMInfo->ewmh._NET_WM_STATE_ABOVE, - pWMInfo->ewmh._NET_WM_STATE_BELOW, - pWMInfo->ewmh._NET_WM_STATE_SKIP_TASKBAR, - }; - - xcb_ewmh_set_supported(&pWMInfo->ewmh, pProcArg->dwScreen, - ARRAY_SIZE(supported), supported); - } - else { - ErrorF("winInitMultiWindowWM - xcb_ewmh_init_atoms() failed\n"); - } - } - - /* Get root window id */ - root_screen = xcb_aux_get_screen(pWMInfo->conn, pProcArg->dwScreen); - root_window_id = root_screen->root; - - /* - Set root window properties for describing multiple desktops to describe - the one desktop we have - */ - { - int data; - const char buf[] = "Desktop"; - - data = 0; - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, root_window_id, - pWMInfo->atmCurrentDesktop, XCB_ATOM_CARDINAL, 32, - 1, &data); - data = 1; - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, root_window_id, - pWMInfo->atmNumberDesktops, XCB_ATOM_CARDINAL, 32, - 1, &data); - - xcb_change_property(pWMInfo->conn, XCB_PROP_MODE_REPLACE, root_window_id, - pWMInfo->atmDesktopNames, pWMInfo->atmUtf8String, 8, - strlen(buf), (unsigned char *) buf); - } - - /* - Set the root window cursor to left_ptr (this controls the cursor an - application gets over its windows when it doesn't set one) - */ - { -#define XC_left_ptr 68 - xcb_cursor_t cursor = xcb_generate_id(pWMInfo->conn); - xcb_font_t font = xcb_generate_id(pWMInfo->conn); - xcb_font_t *mask_font = &font; /* An alias to clarify */ - int shape = XC_left_ptr; - uint32_t mask = XCB_CW_CURSOR; - uint32_t value_list = cursor; - - static const uint16_t fgred = 0, fggreen = 0, fgblue = 0; - static const uint16_t bgred = 0xFFFF, bggreen = 0xFFFF, bgblue = 0xFFFF; - - xcb_open_font(pWMInfo->conn, font, sizeof("cursor"), "cursor"); - - xcb_create_glyph_cursor(pWMInfo->conn, cursor, font, *mask_font, - shape, shape + 1, - fgred, fggreen, fgblue, bgred, bggreen, bgblue); - - xcb_change_window_attributes(pWMInfo->conn, root_window_id, mask, &value_list); - - xcb_free_cursor(pWMInfo->conn, cursor); - xcb_close_font(pWMInfo->conn, font); - } -} - -/* - * winSendMessageToWM - Send a message from the X thread to the WM thread - */ - -void -winSendMessageToWM(void *pWMInfo, winWMMessagePtr pMsg) -{ - WMMsgNodePtr pNode; - -#if CYGMULTIWINDOW_DEBUG - ErrorF("winSendMessageToWM %s\n", MessageName(pMsg)); -#endif - - pNode = malloc(sizeof(WMMsgNodeRec)); - if (pNode != NULL) { - memcpy(&pNode->msg, pMsg, sizeof(winWMMessageRec)); - PushMessage(&((WMInfoPtr) pWMInfo)->wmMsgQueue, pNode); - } -} - -/* - * Check if another window manager is running - */ - -static Bool -CheckAnotherWindowManager(xcb_connection_t *conn, DWORD dwScreen) -{ - Bool redirectError = FALSE; - - /* Get root window id */ - xcb_screen_t *root_screen = xcb_aux_get_screen(conn, dwScreen); - xcb_window_t root_window_id = root_screen->root; - - /* - 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... - */ - const static uint32_t test_mask[] = { XCB_EVENT_MASK_RESIZE_REDIRECT | - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | - XCB_EVENT_MASK_BUTTON_PRESS }; - - xcb_void_cookie_t cookie = xcb_change_window_attributes_checked(conn, - root_window_id, - XCB_CW_EVENT_MASK, - test_mask); - xcb_generic_error_t *error; - if ((error = xcb_request_check(conn, cookie))) - { - redirectError = TRUE; - free(error); - } - - /* - Side effect: select the events we are actually interested in... - - 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... - */ - { - const uint32_t mask[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | - XCB_EVENT_MASK_BUTTON_PRESS }; - - xcb_change_window_attributes(conn, root_window_id, XCB_CW_EVENT_MASK, mask); - } - - return redirectError; -} - -/* - * Notify the MWM thread we're exiting and not to reconnect - */ - -void -winDeinitMultiWindowWM(void) -{ - ErrorF("winDeinitMultiWindowWM - Noting shutdown in progress\n"); - g_shutdown = TRUE; -} - -/* Windows window styles */ -#define HINT_NOFRAME (1L<<0) -#define HINT_BORDER (1L<<1) -#define HINT_SIZEBOX (1L<<2) -#define HINT_CAPTION (1L<<3) -#define HINT_NOMAXIMIZE (1L<<4) -#define HINT_NOMINIMIZE (1L<<5) -#define HINT_NOSYSMENU (1L<<6) -#define HINT_SKIPTASKBAR (1L<<7) -/* These two are used on their own */ -#define HINT_MAX (1L<<0) -#define HINT_MIN (1L<<1) - -static void -winApplyHints(WMInfoPtr pWMInfo, xcb_window_t iWindow, HWND hWnd, HWND * zstyle) -{ - - xcb_connection_t *conn = pWMInfo->conn; - static xcb_atom_t windowState, motif_wm_hints; - static xcb_atom_t hiddenState, fullscreenState, belowState, aboveState, - skiptaskbarState; - static xcb_atom_t splashType; - static int generation; - - unsigned long hint = 0, maxmin = 0; - unsigned long style, exStyle; - - if (!hWnd) - return; - if (!IsWindow(hWnd)) - return; - - if (generation != serverGeneration) { - generation = serverGeneration; - windowState = intern_atom(conn, "_NET_WM_STATE"); - motif_wm_hints = intern_atom(conn, "_MOTIF_WM_HINTS"); - hiddenState = intern_atom(conn, "_NET_WM_STATE_HIDDEN"); - fullscreenState = intern_atom(conn, "_NET_WM_STATE_FULLSCREEN"); - belowState = intern_atom(conn, "_NET_WM_STATE_BELOW"); - aboveState = intern_atom(conn, "_NET_WM_STATE_ABOVE"); - skiptaskbarState = intern_atom(conn, "_NET_WM_STATE_SKIP_TASKBAR"); - splashType = intern_atom(conn, "_NET_WM_WINDOW_TYPE_SPLASHSCREEN"); - } - - { - xcb_get_property_cookie_t cookie_wm_state = xcb_get_property(conn, FALSE, iWindow, windowState, XCB_ATOM_ATOM, 0L, INT_MAX); - xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie_wm_state, NULL); - if (reply) { - int i; - int nitems = xcb_get_property_value_length(reply)/sizeof(xcb_atom_t); - xcb_atom_t *pAtom = xcb_get_property_value(reply); - - for (i = 0; i < nitems; i++) { - if (pAtom[i] == skiptaskbarState) - hint |= HINT_SKIPTASKBAR; - if (pAtom[i] == hiddenState) - maxmin |= HINT_MIN; - else if (pAtom[i] == fullscreenState) - maxmin |= HINT_MAX; - if (pAtom[i] == belowState) - *zstyle = HWND_BOTTOM; - else if (pAtom[i] == aboveState) - *zstyle = HWND_TOPMOST; - } - - free(reply); - } - } - - { - xcb_get_property_cookie_t cookie_mwm_hint = xcb_get_property(conn, FALSE, iWindow, motif_wm_hints, motif_wm_hints, 0L, sizeof(MwmHints)); - xcb_get_property_reply_t *reply = xcb_get_property_reply(conn, cookie_mwm_hint, NULL); - if (reply) { - int nitems = xcb_get_property_value_length(reply)/4; - MwmHints *mwm_hint = xcb_get_property_value(reply); - if (mwm_hint && (nitems >= PropMwmHintsElements) && - (mwm_hint->flags & MwmHintsDecorations)) { - if (!mwm_hint->decorations) - hint |= (HINT_NOFRAME | HINT_NOSYSMENU | HINT_NOMINIMIZE | HINT_NOMAXIMIZE); - 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. - */ - } - } - free(reply); - } - } - - { - int i; - xcb_ewmh_get_atoms_reply_t type; - xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_window_type(&pWMInfo->ewmh, iWindow); - if (xcb_ewmh_get_wm_window_type_reply(&pWMInfo->ewmh, cookie, &type, NULL)) { - for (i = 0; i < type.atoms_len; i++) { - if (type.atoms[i] == pWMInfo->ewmh._NET_WM_WINDOW_TYPE_DOCK) { - hint = (hint & ~HINT_NOFRAME) | HINT_SKIPTASKBAR | HINT_SIZEBOX; - *zstyle = HWND_TOPMOST; - } - else if ((type.atoms[i] == pWMInfo->ewmh._NET_WM_WINDOW_TYPE_SPLASH) - || (type.atoms[i] == splashType)) { - hint |= (HINT_SKIPTASKBAR | HINT_NOSYSMENU | HINT_NOMINIMIZE | HINT_NOMAXIMIZE); - *zstyle = HWND_TOPMOST; - } - } - } - } - - { - xcb_size_hints_t size_hints; - xcb_get_property_cookie_t cookie; - - cookie = xcb_icccm_get_wm_normal_hints(conn, iWindow); - if (xcb_icccm_get_wm_normal_hints_reply(conn, cookie, &size_hints, NULL)) { - if (size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) { - - /* Not maximizable if a maximum size is specified, and that size - is smaller (in either dimension) than the screen size */ - if ((size_hints.max_width < GetSystemMetrics(SM_CXVIRTUALSCREEN)) - || (size_hints.max_height < GetSystemMetrics(SM_CYVIRTUALSCREEN))) - hint |= HINT_NOMAXIMIZE; - - if (size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) { - /* - If both minimum size and maximum size are specified and are the same, - don't bother with a resizing frame - */ - if ((size_hints.min_width == size_hints.max_width) - && (size_hints.min_height == size_hints.max_height)) - hint = (hint & ~HINT_SIZEBOX); - } - } - } - } - - /* - Override hint settings from above with settings from config file and set - application id for grouping. - */ - { - char *application_id = 0; - char *window_name = 0; - char *res_name = 0; - char *res_class = 0; - - GetClassNames(pWMInfo, iWindow, &res_name, &res_class, &window_name); - - style = STYLE_NONE; - style = winOverrideStyle(res_name, res_class, window_name); - -#define APPLICATION_ID_FORMAT "%s.xwin.%s" -#define APPLICATION_ID_UNKNOWN "unknown" - if (res_class) { - asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, - res_class); - } - else { - asprintf(&application_id, APPLICATION_ID_FORMAT, XVENDORNAME, - APPLICATION_ID_UNKNOWN); - } - winSetAppUserModelID(hWnd, application_id); - - free(application_id); - free(res_name); - free(res_class); - free(window_name); - } - - 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_SIZEBOX & ~HINT_CAPTION) | - HINT_BORDER; - else if (style & STYLE_NOFRAME) - hint = - (hint & ~HINT_BORDER & ~HINT_CAPTION & ~HINT_SIZEBOX) | - HINT_NOFRAME; - - /* Now apply styles to window */ - style = GetWindowLongPtr(hWnd, GWL_STYLE); - if (!style) - return; /* GetWindowLongPointer returns 0 on failure, we hope this isn't a valid style */ - - style &= ~WS_CAPTION & ~WS_SIZEBOX; /* Just in case */ - - if (!(hint & ~HINT_SKIPTASKBAR)) /* No hints, default */ - style = style | WS_CAPTION | WS_SIZEBOX; - else if (hint & HINT_NOFRAME) /* No frame, no decorations */ - 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 (hint & HINT_SKIPTASKBAR) - style = style & ~WS_MINIMIZEBOX; /* window will become lost if minimized */ - - SetWindowLongPtr(hWnd, GWL_STYLE, style); - - exStyle = GetWindowLongPtr(hWnd, GWL_EXSTYLE); - if (hint & HINT_SKIPTASKBAR) - exStyle = (exStyle & ~WS_EX_APPWINDOW) | WS_EX_TOOLWINDOW; - else - exStyle = (exStyle & ~WS_EX_TOOLWINDOW) | WS_EX_APPWINDOW; - SetWindowLongPtr(hWnd, GWL_EXSTYLE, exStyle); - - winDebug - ("winApplyHints: iWindow 0x%08x hints 0x%08x style 0x%08x exstyle 0x%08x\n", - iWindow, hint, style, exStyle); -} - -void -winUpdateWindowPosition(HWND hWnd, 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); - - winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - - AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, - GetWindowLongPtr(hWnd, GWL_EXSTYLE)); - - /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */ - if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) { - iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left; - rcNew.left += iDx; - rcNew.right += iDx; - } - - if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN)) { - iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top; - rcNew.top += iDy; - rcNew.bottom += iDy; - } - - winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - - /* Position the Windows window */ - SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); - -} diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c deleted file mode 100644 index 31b5d6307..000000000 --- a/hw/xwin/winmultiwindowwndproc.c +++ /dev/null @@ -1,1250 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - *Copyright (C) Colin Harrison 2005-2008 - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Earle F. Philhower, III - * Harold L Hunt II - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" -#include "dixevents.h" -#include "winmultiwindowclass.h" -#include "winprefs.h" -#include "winmsg.h" -#include "inputstr.h" -#include <dwmapi.h> - -#ifndef WM_DWMCOMPOSITIONCHANGED -#define WM_DWMCOMPOSITIONCHANGED 0x031e -#endif - -extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle); - -/* - * Local globals - */ - -static UINT_PTR g_uipMousePollingTimerID = 0; - -/* - * Constant defines - */ - -#define WIN_MULTIWINDOW_SHAPE YES - -/* - * ConstrainSize - Taken from TWM sources - Respects hints for sizing - */ -#define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) ) -static void -ConstrainSize(WinXSizeHints hints, int *widthp, int *heightp) -{ - int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta; - int baseWidth, baseHeight; - int dwidth = *widthp, dheight = *heightp; - - if (hints.flags & PMinSize) { - minWidth = hints.min_width; - minHeight = hints.min_height; - } - else if (hints.flags & PBaseSize) { - minWidth = hints.base_width; - minHeight = hints.base_height; - } - else - minWidth = minHeight = 1; - - if (hints.flags & PBaseSize) { - baseWidth = hints.base_width; - baseHeight = hints.base_height; - } - else if (hints.flags & PMinSize) { - baseWidth = hints.min_width; - baseHeight = hints.min_height; - } - else - baseWidth = baseHeight = 0; - - if (hints.flags & PMaxSize) { - maxWidth = hints.max_width; - maxHeight = hints.max_height; - } - else { - maxWidth = MAXINT; - maxHeight = MAXINT; - } - - if (hints.flags & PResizeInc) { - xinc = hints.width_inc; - yinc = hints.height_inc; - } - else - xinc = yinc = 1; - - /* - * First, clamp to min and max values - */ - if (dwidth < minWidth) - dwidth = minWidth; - if (dheight < minHeight) - dheight = minHeight; - - if (dwidth > maxWidth) - dwidth = maxWidth; - if (dheight > maxHeight) - dheight = maxHeight; - - /* - * Second, fit to base + N * inc - */ - dwidth = ((dwidth - baseWidth) / xinc * xinc) + baseWidth; - dheight = ((dheight - baseHeight) / yinc * yinc) + baseHeight; - - /* - * Third, adjust for aspect ratio - */ - - /* - * The math looks like this: - * - * minAspectX dwidth maxAspectX - * ---------- <= ------- <= ---------- - * minAspectY dheight maxAspectY - * - * If that is multiplied out, then the width and height are - * invalid in the following situations: - * - * minAspectX * dheight > minAspectY * dwidth - * maxAspectX * dheight < maxAspectY * dwidth - * - */ - - if (hints.flags & PAspect) { - if (hints.min_aspect.x * dheight > hints.min_aspect.y * dwidth) { - delta = - makemult(hints.min_aspect.x * dheight / hints.min_aspect.y - - dwidth, xinc); - if (dwidth + delta <= maxWidth) - dwidth += delta; - else { - delta = - makemult(dheight - - dwidth * hints.min_aspect.y / hints.min_aspect.x, - yinc); - if (dheight - delta >= minHeight) - dheight -= delta; - } - } - - if (hints.max_aspect.x * dheight < hints.max_aspect.y * dwidth) { - delta = - makemult(dwidth * hints.max_aspect.y / hints.max_aspect.x - - dheight, yinc); - if (dheight + delta <= maxHeight) - dheight += delta; - else { - delta = - makemult(dwidth - - hints.max_aspect.x * dheight / hints.max_aspect.y, - xinc); - if (dwidth - delta >= minWidth) - dwidth -= delta; - } - } - } - - /* Return computed values */ - *widthp = dwidth; - *heightp = dheight; -} - -#undef makemult - -/* - * ValidateSizing - Ensures size request respects hints - */ -static int -ValidateSizing(HWND hwnd, WindowPtr pWin, WPARAM wParam, LPARAM lParam) -{ - WinXSizeHints sizeHints; - RECT *rect; - int iWidth, iHeight; - RECT rcClient, rcWindow; - int iBorderWidthX, iBorderWidthY; - - /* Invalid input checking */ - if (pWin == NULL || lParam == 0) - return FALSE; - - /* No size hints, no checking */ - if (!winMultiWindowGetWMNormalHints(pWin, &sizeHints)) - return FALSE; - - /* Avoid divide-by-zero */ - if (sizeHints.flags & PResizeInc) { - if (sizeHints.width_inc == 0) - sizeHints.width_inc = 1; - if (sizeHints.height_inc == 0) - sizeHints.height_inc = 1; - } - - rect = (RECT *) lParam; - - iWidth = rect->right - rect->left; - iHeight = rect->bottom - rect->top; - - /* Now remove size of any borders and title bar */ - GetClientRect(hwnd, &rcClient); - GetWindowRect(hwnd, &rcWindow); - iBorderWidthX = - (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left); - iBorderWidthY = - (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top); - iWidth -= iBorderWidthX; - iHeight -= iBorderWidthY; - - /* Constrain the size to legal values */ - ConstrainSize(sizeHints, &iWidth, &iHeight); - - /* Add back the size of borders and title bar */ - iWidth += iBorderWidthX; - iHeight += iBorderWidthY; - - /* Adjust size according to where we're dragging from */ - switch (wParam) { - case WMSZ_TOP: - case WMSZ_TOPRIGHT: - case WMSZ_BOTTOM: - case WMSZ_BOTTOMRIGHT: - case WMSZ_RIGHT: - rect->right = rect->left + iWidth; - break; - default: - rect->left = rect->right - iWidth; - break; - } - switch (wParam) { - case WMSZ_BOTTOM: - case WMSZ_BOTTOMRIGHT: - case WMSZ_BOTTOMLEFT: - case WMSZ_RIGHT: - case WMSZ_LEFT: - rect->bottom = rect->top + iHeight; - break; - default: - rect->top = rect->bottom - iHeight; - break; - } - return TRUE; -} - -extern Bool winInDestroyWindowsWindow; -static Bool winInRaiseWindow = FALSE; -static void -winRaiseWindow(WindowPtr pWin) -{ - if (!winInDestroyWindowsWindow && !winInRaiseWindow) { - BOOL oldstate = winInRaiseWindow; - XID vlist[1] = { 0 }; - winInRaiseWindow = TRUE; - /* Call configure window directly to make sure it gets processed - * in time - */ - ConfigureWindow(pWin, CWStackMode, vlist, serverClient); - winInRaiseWindow = oldstate; - } -} - -static - void -winStartMousePolling(winPrivScreenPtr s_pScreenPriv) -{ - /* - * Timer to poll mouse position. This is needed to make - * programs like xeyes follow the mouse properly when the - * mouse pointer is outside of any X window. - */ - if (g_uipMousePollingTimerID == 0) - g_uipMousePollingTimerID = SetTimer(s_pScreenPriv->hwndScreen, - WIN_POLLING_MOUSE_TIMER_ID, - MOUSE_POLLING_INTERVAL, NULL); -} - -/* Undocumented */ -typedef struct _ACCENTPOLICY -{ - ULONG AccentState; - ULONG AccentFlags; - ULONG GradientColor; - ULONG AnimationId; -} ACCENTPOLICY; - -#define ACCENT_ENABLE_BLURBEHIND 3 - -typedef struct _WINCOMPATTR -{ - DWORD attribute; - PVOID pData; - ULONG dataSize; -} WINCOMPATTR; - -#define WCA_ACCENT_POLICY 19 - -typedef WINBOOL WINAPI (*PFNSETWINDOWCOMPOSITIONATTRIBUTE)(HWND, WINCOMPATTR *); - -static void -CheckForAlpha(HWND hWnd, WindowPtr pWin, winScreenInfo *pScreenInfo) -{ - /* Check (once) which API we should use */ - static Bool doOnce = TRUE; - static PFNSETWINDOWCOMPOSITIONATTRIBUTE pSetWindowCompositionAttribute = NULL; - static Bool useDwmEnableBlurBehindWindow = FALSE; - - if (doOnce) - { - OSVERSIONINFOEX osvi = {0}; - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx((LPOSVERSIONINFO)&osvi); - - /* SetWindowCompositionAttribute() exists on Windows 7 and later, - but doesn't work for this purpose, so first check for Windows 10 - or later */ - if (osvi.dwMajorVersion >= 10) - { - HMODULE hUser32 = GetModuleHandle("user32"); - - if (hUser32) - pSetWindowCompositionAttribute = (PFNSETWINDOWCOMPOSITIONATTRIBUTE) GetProcAddress(hUser32, "SetWindowCompositionAttribute"); - winDebug("SetWindowCompositionAttribute %s\n", pSetWindowCompositionAttribute ? "found" : "not found"); - } - /* On Windows 7 and Windows Vista, use DwmEnableBlurBehindWindow() */ - else if ((osvi.dwMajorVersion == 6) && (osvi.dwMinorVersion <= 1)) - { - useDwmEnableBlurBehindWindow = TRUE; - } - /* On Windows 8 and Windows 8.1, using the alpha channel on those - seems near impossible, so we don't do anything. */ - - doOnce = FALSE; - } - - /* alpha-channel use is wanted */ - if (!g_fCompositeAlpha || !pScreenInfo->fCompositeWM) - return; - - /* Image has alpha ... */ - if (pWin->drawable.depth != 32) - return; - - /* ... and we can do something useful with it? */ - if (pSetWindowCompositionAttribute) - { - WINBOOL rc; - /* Use the (undocumented) SetWindowCompositionAttribute, if - available, to turn on alpha channel use on Windows 10. */ - ACCENTPOLICY policy = { ACCENT_ENABLE_BLURBEHIND, 0, 0, 0 } ; - WINCOMPATTR data = { WCA_ACCENT_POLICY, &policy, sizeof(ACCENTPOLICY) }; - - /* This turns on DWM looking at the alpha-channel of this window */ - winDebug("enabling alpha for XID %08x hWnd %p, using SetWindowCompositionAttribute()\n", (unsigned int)pWin->drawable.id, hWnd); - rc = pSetWindowCompositionAttribute(hWnd, &data); - if (!rc) - ErrorF("SetWindowCompositionAttribute failed: %d\n", (int)GetLastError()); - } - else if (useDwmEnableBlurBehindWindow) - { - HRESULT rc; - WINBOOL enabled; - - rc = DwmIsCompositionEnabled(&enabled); - if ((rc == S_OK) && enabled) - { - /* Use DwmEnableBlurBehindWindow, to turn on alpha channel - use on Windows Vista and Windows 7 */ - DWM_BLURBEHIND bbh; - bbh.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION | DWM_BB_TRANSITIONONMAXIMIZED; - bbh.fEnable = TRUE; - bbh.hRgnBlur = NULL; - bbh.fTransitionOnMaximized = TRUE; /* What does this do ??? */ - - /* This terribly-named function actually controls if DWM - looks at the alpha channel of this window */ - winDebug("enabling alpha for XID %08x hWnd %p, using DwmEnableBlurBehindWindow()\n", (unsigned int)pWin->drawable.id, hWnd); - rc = DwmEnableBlurBehindWindow(hWnd, &bbh); - if (rc != S_OK) - ErrorF("DwmEnableBlurBehindWindow failed: %x, %d\n", (int)rc, (int)GetLastError()); - } - } -} - -/* - * winTopLevelWindowProc - Window procedure for all top-level Windows windows. - */ - -LRESULT CALLBACK -winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - POINT ptMouse; - 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; - -#if CYGDEBUG - winDebugWin32Message("winTopLevelWindowProc", hwnd, message, wParam, - lParam); -#endif - - /* - If this is WM_CREATE, set up the Windows window properties which point to - X window information, before we populate local convenience variables... - */ - if (message == WM_CREATE) { - SetProp(hwnd, - WIN_WINDOW_PROP, - (HANDLE) ((LPCREATESTRUCT) lParam)->lpCreateParams); - SetProp(hwnd, - WIN_WID_PROP, - (HANDLE) (INT_PTR)winGetWindowID(((LPCREATESTRUCT) lParam)-> - lpCreateParams)); - } - - /* Check if the Windows window property for our X window pointer is valid */ - if ((pWin = GetProp(hwnd, WIN_WINDOW_PROP)) != NULL) { - /* Our X window pointer is valid */ - - /* Get pointers to the drawable and the screen */ - pDraw = &pWin->drawable; - s_pScreen = pWin->drawable.pScreen; - - /* Get a pointer to our window privates */ - pWinPriv = winGetWindowPriv(pWin); - - /* Get pointers to our screen privates and screen info */ - s_pScreenPriv = pWinPriv->pScreenPriv; - s_pScreenInfo = s_pScreenPriv->pScreenInfo; - - /* Get the handle for our screen-sized window */ - hwndScreen = s_pScreenPriv->hwndScreen; - - /* */ - wmMsg.msg = 0; - wmMsg.hwndWindow = hwnd; - wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP); - - wmMsg.iX = pDraw->x; - wmMsg.iY = pDraw->y; - wmMsg.iWidth = pDraw->width; - wmMsg.iHeight = pDraw->height; - - fWMMsgInitialized = TRUE; - -#if 0 - /* - * Print some debugging information - */ - - ErrorF("hWnd %08X\n", hwnd); - ErrorF("pWin %08X\n", pWin); - ErrorF("pDraw %08X\n", pDraw); - ErrorF("\ttype %08X\n", pWin->drawable.type); - ErrorF("\tclass %08X\n", pWin->drawable.class); - ErrorF("\tdepth %08X\n", pWin->drawable.depth); - ErrorF("\tbitsPerPixel %08X\n", pWin->drawable.bitsPerPixel); - ErrorF("\tid %08X\n", pWin->drawable.id); - ErrorF("\tx %08X\n", pWin->drawable.x); - ErrorF("\ty %08X\n", pWin->drawable.y); - ErrorF("\twidth %08X\n", pWin->drawable.width); - ErrorF("\thenght %08X\n", pWin->drawable.height); - ErrorF("\tpScreen %08X\n", pWin->drawable.pScreen); - ErrorF("\tserialNumber %08X\n", pWin->drawable.serialNumber); - ErrorF("g_iWindowPrivateKey %p\n", g_iWindowPrivateKey); - ErrorF("pWinPriv %08X\n", pWinPriv); - ErrorF("s_pScreenPriv %08X\n", s_pScreenPriv); - ErrorF("s_pScreenInfo %08X\n", s_pScreenInfo); - ErrorF("hwndScreen %08X\n", hwndScreen); -#endif - } - - /* Branch on message type */ - switch (message) { - case WM_CREATE: - /* - * Make X windows' Z orders sync with Windows windows because - * there can be AlwaysOnTop windows overlapped on the window - * currently being created. - */ - winReorderWindowsMultiWindow(); - - /* Fix a 'round title bar corner background should be transparent not black' problem when first painted */ - { - RECT rWindow; - HRGN hRgnWindow; - - GetWindowRect(hwnd, &rWindow); - hRgnWindow = CreateRectRgnIndirect(&rWindow); - SetWindowRgn(hwnd, hRgnWindow, TRUE); - DeleteObject(hRgnWindow); - } - - SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) XMING_SIGNATURE); - - CheckForAlpha(hwnd, pWin, s_pScreenInfo); - - return 0; - - case WM_INIT_SYS_MENU: - /* - * Add whatever the setup file wants to for this window - */ - SetupSysMenu(hwnd); - return 0; - - case WM_SYSCOMMAND: - /* - * Any window menu items go through here - */ - if (HandleCustomWM_COMMAND(hwnd, LOWORD(wParam), s_pScreenPriv)) { - /* 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(hwnd, (HMENU)wParam); - break; - - case WM_ERASEBKGND: - /* - * Pretend that we did erase the background but we don't care, - * since we repaint the entire region anyhow - * This avoids some flickering when resizing. - */ - return TRUE; - - case WM_PAINT: - /* Only paint if our window handle is valid */ - if (hwnd == NULL) - break; - -#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... - */ - BeginPaint(hwnd, &ps); - ValidateRect(hwnd, &(ps.rcPaint)); - EndPaint(hwnd, &ps); - } - else -#endif - /* Call the engine dependent repainter */ - if (*s_pScreenPriv->pwinBltExposedWindowRegion) - (*s_pScreenPriv->pwinBltExposedWindowRegion) (s_pScreen, pWin); - - 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); - - return 0; - - case WM_NCMOUSEMOVE: - /* - * We break instead of returning 0 since we need to call - * DefWindowProc to get the mouse cursor changes - * and min/max/close button highlighting in Windows XP. - * The Platform SDK says that you should return 0 if you - * process this message, but it fails to mention that you - * will give up any default functionality if you do return 0. - */ - - /* We can't do anything without privates */ - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - /* Non-client mouse movement, show Windows cursor */ - if (g_fSoftwareCursor && !g_fCursor) { - g_fCursor = TRUE; - ShowCursor(TRUE); - } - - winStartMousePolling(s_pScreenPriv); - - break; - - case WM_MOUSELEAVE: - /* Mouse has left our client area */ - - /* Flag that we are no longer tracking */ - s_fTracking = FALSE; - - /* Show the mouse cursor, if necessary */ - if (g_fSoftwareCursor && !g_fCursor) { - g_fCursor = TRUE; - ShowCursor(TRUE); - } - - winStartMousePolling(s_pScreenPriv); - - return 0; - - case WM_LBUTTONDBLCLK: - case WM_LBUTTONDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[0] = TRUE; - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button1, wParam); - - case WM_LBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[0] = FALSE; - ReleaseCapture(); - winStartMousePolling(s_pScreenPriv); - return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button1, wParam); - - case WM_MBUTTONDBLCLK: - case WM_MBUTTONDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[1] = TRUE; - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button2, wParam); - - case WM_MBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[1] = FALSE; - ReleaseCapture(); - winStartMousePolling(s_pScreenPriv); - return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button2, wParam); - - case WM_RBUTTONDBLCLK: - case WM_RBUTTONDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[2] = TRUE; - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button3, wParam); - - case WM_RBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - g_fButton[2] = FALSE; - ReleaseCapture(); - winStartMousePolling(s_pScreenPriv); - return winMouseButtonsHandle(s_pScreen, ButtonRelease, Button3, wParam); - - case WM_XBUTTONDBLCLK: - case WM_XBUTTONDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7, - wParam); - - case WM_XBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - ReleaseCapture(); - winStartMousePolling(s_pScreenPriv); - return winMouseButtonsHandle(s_pScreen, ButtonRelease, - HIWORD(wParam) + 7, wParam); - - case WM_MOUSEWHEEL: - if (SendMessage - (hwnd, WM_NCHITTEST, 0, - MAKELONG(GET_X_LPARAM(lParam), - GET_Y_LPARAM(lParam))) == HTCLIENT) { - /* Pass the message to the root window */ - SendMessage(hwndScreen, message, wParam, lParam); - return 0; - } - else - break; - - case WM_MOUSEHWHEEL: - if (SendMessage - (hwnd, WM_NCHITTEST, 0, - MAKELONG(GET_X_LPARAM(lParam), - GET_Y_LPARAM(lParam))) == HTCLIENT) { - /* Pass the message to the root window */ - SendMessage(hwndScreen, message, wParam, lParam); - return 0; - } - else - break; - - case WM_SETFOCUS: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - { - /* Get the parent window for transient handling */ - HWND hParent = GetParent(hwnd); - - if (hParent && IsIconic(hParent)) - ShowWindow(hParent, SW_RESTORE); - } - - winRestoreModeKeyStates(); - - /* Add the keyboard hook if possible */ - if (g_fKeyboardHookLL) - g_fKeyboardHookLL = winInstallKeyboardHookLL(); - return 0; - - case WM_KILLFOCUS: - /* Pop any pressed keys since we are losing keyboard focus */ - winKeybdReleaseKeys(); - - /* Remove our keyboard hook if it is installed */ - winRemoveKeyboardHookLL(); - - /* 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; - - case WM_SYSDEADCHAR: - case WM_DEADCHAR: - /* - * NOTE: We do nothing with WM_*CHAR messages, - * nor does the root window, so we can just toss these messages. - */ - return 0; - - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - - /* - * Don't pass Alt-F4 key combo to root window, - * let Windows translate to WM_CLOSE and close this top-level window. - * - * NOTE: We purposely don't check the fUseWinKillKey setting because - * it should only apply to the key handling for the root window, - * not for top-level window-manager windows. - * - * ALSO NOTE: We do pass Ctrl-Alt-Backspace to the root window - * because that is a key combo that no X app should be expecting to - * receive, since it has historically been used to shutdown the X server. - * Passing Ctrl-Alt-Backspace to the root window preserves that - * behavior, assuming that -unixkill has been passed as a parameter. - */ - if (wParam == VK_F4 && (GetKeyState(VK_MENU) & 0x8000)) - break; - -#if CYGWINDOWING_DEBUG - 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; - ErrorF("\nCYGWINDOWING Dump:\n" - "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x, - pDraw->y, pDraw->width, pDraw->height); - ErrorF("\twindPlace: (%d, %d) - %dx%d\n", (int)pRect->left, - (int)pRect->top, (int)(pRect->right - pRect->left), - (int)(pRect->bottom - pRect->top)); - if (GetClientRect(hwnd, &rc)) { - pRect = &rc; - ErrorF("\tClientRect: (%d, %d) - %dx%d\n", (int)pRect->left, - (int)pRect->top, (int)(pRect->right - pRect->left), - (int)(pRect->bottom - pRect->top)); - } - if (GetWindowRect(hwnd, &rc)) { - pRect = &rc; - ErrorF("\tWindowRect: (%d, %d) - %dx%d\n", (int)pRect->left, - (int)pRect->top, (int)(pRect->right - pRect->left), - (int)(pRect->bottom - pRect->top)); - } - ErrorF("\n"); - } -#endif - - /* Pass the message to the root window */ - return winWindowProc(hwndScreen, message, wParam, lParam); - - case WM_SYSKEYUP: - case WM_KEYUP: - - /* Pass the message to the root window */ - return winWindowProc(hwndScreen, message, wParam, lParam); - - case WM_HOTKEY: - - /* Pass the message to the root window */ - SendMessage(hwndScreen, message, wParam, lParam); - return 0; - - case WM_ACTIVATE: - - /* Pass the message to the root window */ - SendMessage(hwndScreen, message, wParam, lParam); - - if (LOWORD(wParam) != WA_INACTIVE) { - /* Raise the window to the top in Z order */ - /* ago: Activate does not mean putting it to front! */ - /* - wmMsg.msg = WM_WM_RAISE; - if (fWMMsgInitialized) - winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg); - */ - - /* Tell our Window Manager thread to activate the window */ - wmMsg.msg = WM_WM_ACTIVATE; - if (fWMMsgInitialized) - if (!pWin || !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 != GetParent(hwnd)) - SetFocus(hwnd); - return 0; - - case WM_ACTIVATEAPP: - /* - * This message is also sent to the root window - * so we do nothing for individual multiwindow windows - */ - break; - - case WM_CLOSE: - /* Remove AppUserModelID property */ - winSetAppUserModelID(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; - - case WM_DESTROY: - - /* Branch on if the window was killed in X already */ - if (pWinPriv && !pWinPriv->fXKilled) { - ErrorF("winTopLevelWindowProc - WM_DESTROY - WM_WM_KILL\n"); - - /* Tell our Window Manager thread to kill the window */ - wmMsg.msg = WM_WM_KILL; - if (fWMMsgInitialized) - winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); - } - - RemoveProp(hwnd, WIN_WINDOW_PROP); - RemoveProp(hwnd, WIN_WID_PROP); - RemoveProp(hwnd, WIN_NEEDMANAGE_PROP); - - break; - - case WM_MOVE: - /* Adjust the X Window to the moved Windows window */ - 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) { - HWND zstyle = HWND_NOTOPMOST; - - /* Flag that this window needs to be made active when clicked */ - SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1); - - /* 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, &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_MAP_MANAGED; - } - else { /* It is an overridden window so make it top of Z stack */ - - HWND forHwnd = GetForegroundWindow(); - -#if CYGWINDOWING_DEBUG - ErrorF("overridden window is shown\n"); -#endif - if (forHwnd != NULL) { - if (GetWindowLongPtr(forHwnd, GWLP_USERDATA) & (LONG_PTR) - XMING_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_MAP_UNMANAGED; - } - - /* Tell our Window Manager thread to map the window */ - if (fWMMsgInitialized) - winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); - - winStartMousePolling(s_pScreenPriv); - - return 0; - - case WM_SIZING: - /* Need to legalize the size according to WM_NORMAL_HINTS */ - /* for applications like xterm */ - return ValidateSizing(hwnd, pWin, wParam, lParam); - - case WM_WINDOWPOSCHANGED: - { - LPWINDOWPOS pWinPos = (LPWINDOWPOS) lParam; - - if (!(pWinPos->flags & SWP_NOZORDER)) { -#if CYGWINDOWING_DEBUG - winDebug("\twindow z order was changed\n"); -#endif - if (pWinPos->hwndInsertAfter == HWND_TOP - || pWinPos->hwndInsertAfter == HWND_TOPMOST - || pWinPos->hwndInsertAfter == HWND_NOTOPMOST) { -#if CYGWINDOWING_DEBUG - winDebug("\traise to top\n"); -#endif - /* Raise the window to the top in Z order */ - winRaiseWindow(pWin); - } - else if (pWinPos->hwndInsertAfter == HWND_BOTTOM) { - } - else { - /* Check if this window is top of X windows. */ - HWND hWndAbove = NULL; - DWORD dwCurrentProcessID = GetCurrentProcessId(); - DWORD dwWindowProcessID = 0; - - for (hWndAbove = pWinPos->hwndInsertAfter; - hWndAbove != NULL; - hWndAbove = GetNextWindow(hWndAbove, GW_HWNDPREV)) { - /* Ignore other XWin process's window */ - GetWindowThreadProcessId(hWndAbove, &dwWindowProcessID); - - if ((dwWindowProcessID == dwCurrentProcessID) - && GetProp(hWndAbove, WIN_WINDOW_PROP) - && !IsWindowVisible(hWndAbove) - && !IsIconic(hWndAbove)) /* ignore minimized windows */ - break; - } - /* If this is top of X windows in Windows stack, - raise it in X stack. */ - if (hWndAbove == NULL) { -#if CYGWINDOWING_DEBUG - winDebug("\traise to top\n"); -#endif - winRaiseWindow(pWin); - } - } - } - } - /* - * Pass the message to DefWindowProc to let the function - * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE. - */ - break; - - case WM_ENTERSIZEMOVE: - hasEnteredSizeMove = TRUE; - return 0; - - case WM_EXITSIZEMOVE: - /* Adjust the X Window to the moved Windows window */ - hasEnteredSizeMove = FALSE; - winAdjustXWindow(pWin, hwnd); - return 0; - - case WM_SIZE: - /* see dix/window.c */ -#if CYGWINDOWING_DEBUG - { - 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"); - } - ErrorF("winTopLevelWindowProc - WM_SIZE to %dx%d (%s)\n", - (int) LOWORD(lParam), (int) HIWORD(lParam), buf); - } -#endif - if (!hasEnteredSizeMove) { - /* Adjust the X Window to the moved Windows window */ - winAdjustXWindow(pWin, hwnd); - } - /* else: wait for WM_EXITSIZEMOVE */ - return 0; /* end of WM_SIZE handler */ - - case WM_STYLECHANGING: - /* - When the style changes, adjust the Windows window size so the client area remains the same size, - and adjust the Windows window position so that the client area remains in the same place. - */ - { - RECT newWinRect; - DWORD dwExStyle; - DWORD dwStyle; - DWORD newStyle = ((STYLESTRUCT *) lParam)->styleNew; - WINDOWINFO wi; - - dwExStyle = GetWindowLongPtr(hwnd, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr(hwnd, GWL_STYLE); - - winDebug("winTopLevelWindowProc - WM_STYLECHANGING from %08x %08x\n", - (unsigned int)dwStyle, (unsigned int)dwExStyle); - - if (wParam == GWL_EXSTYLE) - dwExStyle = newStyle; - - if (wParam == GWL_STYLE) - dwStyle = newStyle; - - winDebug("winTopLevelWindowProc - WM_STYLECHANGING to %08x %08x\n", - (unsigned int)dwStyle, (unsigned int)dwExStyle); - - /* Get client rect in screen coordinates */ - wi.cbSize = sizeof(WINDOWINFO); - GetWindowInfo(hwnd, &wi); - - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING client area {%d, %d, %d, %d}, {%d x %d}\n", - (int)wi.rcClient.left, (int)wi.rcClient.top, (int)wi.rcClient.right, - (int)wi.rcClient.bottom, (int)(wi.rcClient.right - wi.rcClient.left), - (int)(wi.rcClient.bottom - wi.rcClient.top)); - - newWinRect = wi.rcClient; - if (!AdjustWindowRectEx(&newWinRect, dwStyle, FALSE, dwExStyle)) - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING AdjustWindowRectEx failed\n"); - - winDebug - ("winTopLevelWindowProc - WM_STYLECHANGING window area should be {%d, %d, %d, %d}, {%d x %d}\n", - (int)newWinRect.left, (int)newWinRect.top, (int)newWinRect.right, - (int)newWinRect.bottom, (int)(newWinRect.right - newWinRect.left), - (int)(newWinRect.bottom - newWinRect.top)); - - /* - Style change hasn't happened yet, so we can't adjust the window size yet, as the winAdjustXWindow() - which WM_SIZE does will use the current (unchanged) style. Instead make a note to change it when - WM_STYLECHANGED is received... - */ - pWinPriv->hDwp = BeginDeferWindowPos(1); - pWinPriv->hDwp = - DeferWindowPos(pWinPriv->hDwp, hwnd, NULL, newWinRect.left, - newWinRect.top, newWinRect.right - newWinRect.left, - newWinRect.bottom - newWinRect.top, - SWP_NOACTIVATE | SWP_NOZORDER); - } - return 0; - - case WM_STYLECHANGED: - { - if (pWinPriv->hDwp) { - EndDeferWindowPos(pWinPriv->hDwp); - pWinPriv->hDwp = NULL; - } - winDebug("winTopLevelWindowProc - WM_STYLECHANGED done\n"); - } - return 0; - - case WM_MOUSEACTIVATE: - - /* Check if this window needs to be made active when clicked */ - if (!GetProp(pWinPriv->hWnd, WIN_NEEDMANAGE_PROP)) { -#if CYGMULTIWINDOW_DEBUG - ErrorF("winTopLevelWindowProc - WM_MOUSEACTIVATE - " - "MA_NOACTIVATE\n"); -#endif - - /* */ - return MA_NOACTIVATE; - } - break; - - case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT) { - if (!g_fSoftwareCursor) - SetCursor(s_pScreenPriv->cursor.handle); - return TRUE; - } - break; - - - case WM_DWMCOMPOSITIONCHANGED: - /* This message is only sent on Vista/W7 */ - CheckForAlpha(hwnd, pWin, s_pScreenInfo); - - return 0; - default: - break; - } - - ret = DefWindowProc(hwnd, message, wParam, lParam); - /* - * If the window was minized we get the stack change before the window is restored - * and so it gets lost. Ensure there stacking order is correct. - */ - if (needRestack) - winReorderWindowsMultiWindow(); - return ret; -} diff --git a/hw/xwin/winos.c b/hw/xwin/winos.c deleted file mode 100644 index 0d825bb83..000000000 --- a/hw/xwin/winos.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2010-2014 Colin Harrison All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name(s) of the above copyright - * holders shall not be used in advertising or otherwise to promote the sale, - * use or other dealings in this Software without prior written authorization. - * - * Author: Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS)(HANDLE, PBOOL); - -static const char* -IsWow64(void) -{ -#ifdef __x86_64__ - return " (64-bit)"; -#else - WINBOOL bIsWow64; - LPFN_ISWOW64PROCESS fnIsWow64Process = - (LPFN_ISWOW64PROCESS) GetProcAddress(GetModuleHandle(TEXT("kernel32")), - "IsWow64Process"); - if (NULL != fnIsWow64Process) { - if (fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) - return bIsWow64 ? " (WoW64)" : " (32-bit)"; - } - - /* OS doesn't support IsWow64Process() */ - return ""; -#endif -} - -/* - * Report the OS version - */ - -void -winOS(void) -{ - OSVERSIONINFOEX osvi = {0}; - - /* Get operating system version information */ - osvi.dwOSVersionInfoSize = sizeof(osvi); - GetVersionEx((LPOSVERSIONINFO)&osvi); - - ErrorF("OS: Windows NT %d.%d build %d%s\n", - (int)osvi.dwMajorVersion, (int)osvi.dwMinorVersion, - (int)osvi.dwBuildNumber, IsWow64()); -} diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c deleted file mode 100644 index d0b2ef2e7..000000000 --- a/hw/xwin/winprefs.c +++ /dev/null @@ -1,805 +0,0 @@ -/* - * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * Copyright (C) Colin Harrison 2005-2008 - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - * Colin Harrison - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#ifdef __CYGWIN__ -#include <sys/resource.h> -#include <sys/cygwin.h> -#endif -#include "win.h" - -#include <X11/Xwindows.h> -#include <shellapi.h> - -#include "winprefs.h" -#include "windisplay.h" -#include "winmultiwindowclass.h" -#include "winmultiwindowicons.h" - -/* Where will the custom menu commands start counting from? */ -#define STARTMENUID WM_USER - -extern const char *winGetBaseDir(void); - -/* From winprefslex.l, the real parser */ -extern int parse_file(FILE * fp); - -/* Currently in use command ID, incremented each new menu item created */ -static int g_cmdid = STARTMENUID; - -/* - * Creates or appends a menu from a MENUPARSED structure - */ -static HMENU -MakeMenu(char *name, HMENU editMenu, int editItem) -{ - int i; - int item; - MENUPARSED *m; - HMENU hmenu, hsub; - - for (i = 0; i < pref.menuItems; i++) { - if (!strcmp(name, pref.menu[i].menuName)) - break; - } - - /* Didn't find a match, bummer */ - if (i == pref.menuItems) { - ErrorF("MakeMenu: Can't find menu %s\n", name); - return NULL; - } - - m = &(pref.menu[i]); - - if (editMenu) { - hmenu = editMenu; - item = editItem; - } - else { - hmenu = CreatePopupMenu(); - if (!hmenu) { - ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name); - return NULL; - } - item = 0; - } - - /* Add the menu items */ - for (i = 0; i < m->menuItems; i++) { - /* Only assign IDs one time... */ - if (m->menuItem[i].commandID == 0) - m->menuItem[i].commandID = g_cmdid++; - - switch (m->menuItem[i].cmd) { - case CMD_EXEC: - case CMD_ALWAYSONTOP: - case CMD_RELOAD: - InsertMenu(hmenu, - item, - MF_BYPOSITION | MF_ENABLED | MF_STRING, - m->menuItem[i].commandID, m->menuItem[i].text); - break; - - case CMD_SEPARATOR: - InsertMenu(hmenu, item, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - break; - - case CMD_MENU: - /* Recursive! */ - hsub = MakeMenu(m->menuItem[i].param, 0, 0); - if (hsub) - InsertMenu(hmenu, - item, - MF_BYPOSITION | MF_POPUP | MF_ENABLED | MF_STRING, - (UINT_PTR) hsub, m->menuItem[i].text); - break; - } - - /* If item==-1 (means to add at end of menu) don't increment) */ - if (item >= 0) - item++; - } - - return hmenu; -} - -/* - * Callback routine that is executed once per window class. - * Removes or creates custom window settings depending on LPARAM - */ -static wBOOL CALLBACK -ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam) -{ - HICON hicon; - - if (!hwnd) { - ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n"); - return FALSE; - } - - /* It's our baby, either clean or dirty it */ - if (lParam == FALSE) { - /* Reset the window's icon to undefined. */ - hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_BIG, 0); - - /* If the old icon is generated on-the-fly, get rid of it, will regen */ - winDestroyIcon(hicon); - - /* Same for the small icon */ - hicon = (HICON) SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0); - winDestroyIcon(hicon); - - /* Remove any menu additions; bRevert=TRUE destroys any modified menus */ - GetSystemMenu(hwnd, TRUE); - - /* This window is now clean of our taint (but with undefined icons) */ - } - else { - /* Send a message to WM thread telling it re-evaluate the icon for this window */ - { - winWMMessageRec wmMsg; - - WindowPtr pWin = GetProp(hwnd, WIN_WINDOW_PROP); - - if (pWin) { - winPrivWinPtr pWinPriv = winGetWindowPriv(pWin); - winPrivScreenPtr s_pScreenPriv = pWinPriv->pScreenPriv; - - wmMsg.msg = WM_WM_ICON_EVENT; - wmMsg.hwndWindow = hwnd; - wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP); - - winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); - } - } - - /* Update the system menu for this window */ - SetupSysMenu(hwnd); - - /* That was easy... */ - } - - return TRUE; -} - -/* - * Removes any custom icons in classes, custom menus, etc. - * Frees all members in pref structure. - * Reloads the preferences file. - * Set custom icons and menus again. - */ -static void -ReloadPrefs(winPrivScreenPtr pScreenPriv) -{ - int i; - - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* 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. - */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE); - - /* 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; - - if (pScreenInfo->fMultiWindow) { - winInitGlobalIcons(); - - /* Rebuild the icons and menus */ - EnumThreadWindows(g_dwCurrentThreadID, ReloadEnumWindowsProc, TRUE); - } - - /* Whew, done */ -} - -/* - * Check/uncheck the ALWAYSONTOP items in this menu - */ -void -HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu) -{ - DWORD dwExStyle; - int i, j; - - 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 processed, FALSE otherwise. - */ -Bool -HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv) -{ - int i, j; - MENUPARSED *m; - DWORD dwExStyle; - - 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; - int fd; - - /* Close any open descriptors except for STD* */ - getrlimit(RLIMIT_NOFILE, &rl); - for (fd = STDERR_FILENO + 1; fd < rl.rlim_cur; fd++) - close(fd); - - /* 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, - "Mingrc 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); - { - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - if (pScreenInfo->fMultiWindow) - /* Reflect the changed Z order */ - winReorderWindowsMultiWindow(); - } - return TRUE; - - case CMD_RELOAD: - ReloadPrefs(pScreenPriv); - return TRUE; - - default: - return FALSE; - } - } /* match */ - } /* for j */ - } /* for i */ - - return FALSE; -} - -/* - * Add the default or a custom menu depending on the class match - */ -void -SetupSysMenu(HWND hwnd) -{ - HMENU sys; - int i; - WindowPtr pWin; - char *res_name, *res_class; - - 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); - } -} - -/* - * Possibly add a menu to the toolbar icon - */ -void -SetupRootMenu(HMENU root) -{ - if (!root) - return; - - if (pref.rootMenuName[0]) { - MakeMenu(pref.rootMenuName, root, 0); - } -} - -/* - * Check for and return an overridden default ICON specified in the prefs - */ -HICON -winOverrideDefaultIcon(int size) -{ - HICON hicon; - - if (pref.defaultIconName[0]) { - hicon = LoadImageComma(pref.defaultIconName, pref.iconDirectory, size, size, 0); - if (hicon == NULL) - ErrorF("winOverrideDefaultIcon: LoadImageComma(%s) failed\n", - pref.defaultIconName); - - return hicon; - } - - return 0; -} - -/* - * Return the HICON to use in the taskbar notification area - */ -HICON -winTaskbarIcon(void) -{ - HICON hicon; - - hicon = 0; - /* First try and load an overridden, if success then return it */ - if (pref.trayIconName[0]) { - hicon = LoadImageComma(pref.trayIconName, pref.iconDirectory, - GetSystemMetrics(SM_CXSMICON), - GetSystemMetrics(SM_CYSMICON), 0); - if (hicon == NULL) - ErrorF("winTaskbarIcon: LoadImageComma(%s) failed\n", - pref.trayIconName); - } - - /* 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; -} - -/* - * Handle comma-ified icon names - * - * Parse a filename to extract an icon: - * If fname is exactly ",nnn" then extract icon from our resource - * else if it is "file,nnn" then extract icon nnn from that file - * else try to load it as an .ico file and if that fails return NULL - */ -HICON -LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags) -{ - HICON hicon; - int i; - - /* Some input error checking */ - if (!fname || !fname[0]) - return NULL; - - i = 0; - hicon = NULL; - - if (fname[0] == ',') { - /* It's the XWIN.EXE resource they want */ - i = atoi(fname + 1); - hicon = LoadImage(g_hInstance, - MAKEINTRESOURCE(i), IMAGE_ICON, sx, sy, flags); - } - else { - char *file = malloc(PATH_MAX + NAME_MAX + 2); - Bool convert = FALSE; - - if (!file) - return NULL; - - file[0] = 0; - - /* If fname starts 'X:\', it's an absolute Windows path, do nothing */ - if (!(fname[0] && fname[1] == ':' && fname[2] == '\\')) { -#ifdef __CYGWIN__ - /* If fname starts with '/', it's an absolute cygwin path, we'll - need to convert it */ - if (fname[0] == '/') { - convert = TRUE; - } - else -#endif - if (iconDirectory) { - /* Otherwise, prepend the default icon directory, which - currently must be in absolute Windows path form */ - strcpy(file, iconDirectory); - if (iconDirectory[0]) - if (iconDirectory[strlen(iconDirectory) - 1] != '\\') - strcat(file, "\\"); - } - } - strcat(file, fname); - - /* Trim off any ',index' */ - if (strrchr(file, ',')) { - *(strrchr(file, ',')) = 0; /* End string at comma */ - i = atoi(strrchr(fname, ',') + 1); - } - else { - i = -1; - } - -#ifdef __CYGWIN__ - /* Convert from Cygwin path to Windows path */ - if (convert) { - char *converted_file = cygwin_create_path(CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, file); - if (converted_file) { - free(file); - file = converted_file; - } - } -#endif - - if (i >= 0) { - /* Specified as <fname>,<index> */ - hicon = ExtractIcon(g_hInstance, file, i); - } - else { - /* Specified as just an .ico file */ - hicon = (HICON) LoadImage(NULL, - file, - IMAGE_ICON, - sx, sy, LR_LOADFROMFILE | flags); - } - free(file); - } - return hicon; -} - -/* - * Check for a match of the window class to one specified in the - * ICONS{} section in the prefs file, and load the icon from a file - */ -HICON -winOverrideIcon(char *res_name, char *res_class, char *wmName) -{ - int i; - HICON hicon; - - for (i = 0; i < pref.iconItems; i++) { - if ((res_name && !strcmp(pref.icon[i].match, res_name)) || - (res_class && !strcmp(pref.icon[i].match, res_class)) || - (wmName && strstr(wmName, pref.icon[i].match))) { - if (pref.icon[i].hicon) - return pref.icon[i].hicon; - - hicon = LoadImageComma(pref.icon[i].iconFile, pref.iconDirectory, 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 */ - return 0; -} - -/* - * Should we free this icon or leave it in memory (is it part of our - * ICONS{} overrides)? - */ -int -winIconIsOverride(HICON hicon) -{ - int i; - - 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(const char *path) -{ - FILE *prefFile = NULL; - - if (path) - prefFile = fopen(path, "r"); -#ifdef __CYGWIN__ - 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; - } - - ErrorF("LoadPreferences: Loading %s\n", path); - - if ((parse_file(prefFile)) != 0) { - ErrorF("LoadPreferences: %s is badly formed!\n", path); - fclose(prefFile); - return FALSE; - } - - fclose(prefFile); - return TRUE; -} - -/* - * Try and open ~/.XWinrc and system.XWinrc - * Load it into prefs structure for use by other functions - */ -void -LoadPreferences(void) -{ - char *home; - char fname[PATH_MAX + NAME_MAX + 2]; - 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]; - -#ifdef RELOCATE_PROJECTROOT - snprintf(buffer, sizeof(buffer), "%s\\system.XWinrc", winGetBaseDir()); -#else - strncpy(buffer, SYSCONFDIR "/X11/system.XWinrc", sizeof(buffer)); -#endif - buffer[sizeof(buffer) - 1] = 0; - 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); - } - - /* Setup a DISPLAY environment variable, need to allocate on heap */ - /* because putenv doesn't copy the argument... */ - winGetDisplayName(szDisplay, 0); - szEnvDisplay = (char *) (malloc(strlen(szDisplay) + strlen("DISPLAY=") + 1)); - if (szEnvDisplay) { - 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 { - *dstParam = *srcParam; - dstParam++; - srcParam++; - } - } - *dstParam = 0; - strcpy(pref.menu[i].menuItem[j].param, param); - } /* cmd==cmd_exec */ - } /* for all menuitems */ - } /* for all menus */ - -} - -/* - * Check for a match of the window class to one specified in the - * STYLES{} section in the prefs file, and return the style type - */ -unsigned long -winOverrideStyle(char *res_name, char *res_class, char *wmName) -{ - int i; - - for (i = 0; i < pref.styleItems; i++) { - if ((res_name && !strcmp(pref.style[i].match, res_name)) || - (res_class && !strcmp(pref.style[i].match, res_class)) || - (wmName && strstr(wmName, pref.style[i].match))) { - if (pref.style[i].type) - return pref.style[i].type; - } - } - - /* Didn't find the style, fail gracefully */ - return STYLE_NONE; -} diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h deleted file mode 100644 index 597398ee2..000000000 --- a/hw/xwin/winprefs.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * Copyright (C) Colin Harrison 2005-2008 - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - * Colin Harrison - */ - -#if !defined(WINPREFS_H) -#define WINPREFS_H - -/* Need Bool */ -#include <X11/Xdefs.h> -/* Need TRUE */ -#include "misc.h" - -/* Need to know how long paths can be... */ -#include <limits.h> -/* Xwindows redefines PATH_MAX to at least 1024 */ -#include <X11/Xwindows.h> - -#include "winwindow.h" - -#ifndef NAME_MAX -#define NAME_MAX PATH_MAX -#endif -#define MENU_MAX 128 /* Maximum string length of a menu name or item */ -#define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */ - -/* Supported commands in a MENU {} statement */ -typedef enum MENUCOMMANDTYPE { - CMD_EXEC, /* /bin/sh -c the parameter */ - CMD_MENU, /* Display a popup menu named param */ - CMD_SEPARATOR, /* Menu separator */ - CMD_ALWAYSONTOP, /* Toggle always-on-top mode */ - CMD_RELOAD /* Reparse the .XWINRC file */ -} MENUCOMMANDTYPE; - -#define STYLE_NONE (0L) /* Dummy the first entry */ -#define STYLE_NOTITLE (1L) /* Force window style no titlebar */ -#define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */ -#define STYLE_NOFRAME (1L<<2) /* Force window style no frame */ -#define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */ -#define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */ -#define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */ -#define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */ - -/* Where to place a system menu */ -typedef enum MENUPOSITION { - AT_START, /* Place menu at the top of the system menu */ - AT_END /* Put it at the bottom of the menu (default) */ -} MENUPOSITION; - -/* Menu item definitions */ -typedef struct MENUITEM { - char text[MENU_MAX + 1]; /* To be displayed in menu */ - MENUCOMMANDTYPE cmd; /* What should it do? */ - char param[PARAM_MAX + 1]; /* Any parameters? */ - unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */ -} MENUITEM; - -/* A completely read in menu... */ -typedef struct MENUPARSED { - char menuName[MENU_MAX + 1]; /* What's it called in the text? */ - MENUITEM *menuItem; /* Array of items */ - int menuItems; /* How big's the array? */ -} MENUPARSED; - -/* To map between a window and a system menu to add for it */ -typedef struct SYSMENUITEM { - char match[MENU_MAX + 1]; /* String to look for to apply this sysmenu */ - char menuName[MENU_MAX + 1]; /* Which menu to show? Used to set *menu */ - MENUPOSITION menuPos; /* Where to place it (ignored in root) */ -} SYSMENUITEM; - -/* To redefine icons for certain window types */ -typedef struct ICONITEM { - char match[MENU_MAX + 1]; /* What string to search for? */ - char iconFile[PATH_MAX + NAME_MAX + 2]; /* Icon location, WIN32 path */ - HICON hicon; /* LoadImage() result */ -} ICONITEM; - -/* To redefine styles for certain window types */ -typedef struct STYLEITEM { - char match[MENU_MAX + 1]; /* What string to search for? */ - unsigned long type; /* What should it do? */ -} STYLEITEM; - -typedef struct WINPREFS { - /* Menu information */ - MENUPARSED *menu; /* Array of created menus */ - int menuItems; /* How big? */ - - /* Taskbar menu settings */ - char rootMenuName[MENU_MAX + 1]; /* Menu for taskbar icon */ - - /* System menu addition menus */ - SYSMENUITEM *sysMenu; - int sysMenuItems; - - /* Which menu to add to unmatched windows? */ - char defaultSysMenuName[MENU_MAX + 1]; - MENUPOSITION defaultSysMenuPos; /* Where to place it */ - - /* Icon information */ - char iconDirectory[PATH_MAX + 1]; /* Where do the .icos lie? (Win32 path) */ - char defaultIconName[NAME_MAX + 1]; /* Replacement for x.ico */ - char trayIconName[NAME_MAX + 1]; /* Replacement for tray icon */ - - ICONITEM *icon; - int iconItems; - - STYLEITEM *style; - int styleItems; - - /* Force exit flag */ - Bool fForceExit; - - /* Silent exit flag */ - Bool fSilentExit; - -} WINPREFS; - -/* The global pref settings structure loaded by the winprefyacc.y parser */ -extern WINPREFS pref; - -/* Functions */ -void - LoadPreferences(void); - -void - SetupRootMenu(HMENU root); - -void - SetupSysMenu(HWND hwnd); - -void - HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu); - -Bool - HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv); - -int - winIconIsOverride(HICON hicon); - -HICON winOverrideIcon(char *res_name, char *res_class, char *wmName); - -unsigned long - winOverrideStyle(char *res_name, char *res_class, char *wmName); - -HICON winTaskbarIcon(void); - -HICON winOverrideDefaultIcon(int size); - -HICON LoadImageComma(char *fname, char *iconDirectory, int sx, int sy, int flags); - -#endif diff --git a/hw/xwin/winprefslex.l b/hw/xwin/winprefslex.l deleted file mode 100644 index 9e6f0d6d4..000000000 --- a/hw/xwin/winprefslex.l +++ /dev/null @@ -1,128 +0,0 @@ -%{ # -*- C -*- -/* - * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * Copyright (C) Colin Harrison 2005-2008 - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - * Colin Harrison - */ -/* $XFree86: $ */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "winprefsyacc.h" - -extern void ErrorF (const char* /*f*/, ...); - -/* Copy the parsed string, must be free()d in yacc parser */ -static char *makestr(char *str) -{ - char *ptr; - ptr = malloc(strlen(str)+1); - if (!ptr) - { - ErrorF ("winMultiWindowLex:makestr() out of memory\n"); - exit (-1); - } - strcpy(ptr, str); - return ptr; -} - -%} - -%option yylineno -%option nounput -%option noinput -%option never-interactive - -%% -\#.*[\r\n] { /* comment */ return NEWLINE; } -\/\/.*[\r\n] { /* comment */ return NEWLINE; } -[\r\n] { return NEWLINE; } -[ \t]+ { /* ignore whitespace */ } -MENU { return MENU; } -ICONDIRECTORY { return ICONDIRECTORY; } -DEFAULTICON { return DEFAULTICON; } -ICONS { return ICONS; } -STYLES { return STYLES; } -TOPMOST { return TOPMOST; } -MAXIMIZE { return MAXIMIZE; } -MINIMIZE { return MINIMIZE; } -BOTTOM { return BOTTOM; } -NOTITLE { return NOTITLE; } -OUTLINE { return OUTLINE; } -NOFRAME { return NOFRAME; } -ROOTMENU { return ROOTMENU; } -DEFAULTSYSMENU { return DEFAULTSYSMENU; } -SYSMENU { return SYSMENU; } -SEPARATOR { return SEPARATOR; } -ATSTART { return ATSTART; } -ATEND { return ATEND; } -EXEC { return EXEC; } -ALWAYSONTOP { return ALWAYSONTOP; } -DEBUG { return DEBUGOUTPUT; } -RELOAD { return RELOAD; } -TRAYICON { return TRAYICON; } -FORCEEXIT { return FORCEEXIT; } -SILENTEXIT { return SILENTEXIT; } -"{" { return LB; } -"}" { return RB; } -"\""[^\"\r\n]+"\"" { yylval.sVal = makestr(yytext+1); \ - yylval.sVal[strlen(yylval.sVal)-1] = 0; \ - return STRING; } -[^ \t\r\n]+ { yylval.sVal = makestr(yytext); \ - return STRING; } -%% - -/* - * Run-of-the mill requirement for yacc - */ -int -yywrap (void) -{ - return 1; -} - -/* - * Run a file through the yacc parser - */ -int -parse_file (FILE *file) -{ - int ret; - - if (!file) - return 1; - - yylineno = 1; - yyin = file; - ret = yyparse (); - yylex_destroy (); - return ret; -} - diff --git a/hw/xwin/winprefsyacc.y b/hw/xwin/winprefsyacc.y deleted file mode 100644 index 9bb28ae92..000000000 --- a/hw/xwin/winprefsyacc.y +++ /dev/null @@ -1,451 +0,0 @@ -%{ -/* - * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * Copyright (C) Colin Harrison 2005-2008 - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - * - * Authors: Earle F. Philhower, III - * Colin Harrison - */ -/* $XFree86: $ */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include <stdio.h> -#include <stdlib.h> -#define _STDLIB_H 1 /* bison checks this to know if stdlib has been included */ -#include <string.h> -#include "winprefs.h" - -/* The following give better error messages in bison at the cost of a few KB */ -#define YYERROR_VERBOSE 1 - -/* YYLTYPE_IS_TRIVIAL and YYENABLE_NLS defined to suppress warnings */ -#define YYLTYPE_IS_TRIVIAL 1 -#define YYENABLE_NLS 0 - -/* The global pref settings */ -WINPREFS pref; - -/* The working menu */ -static MENUPARSED menu; - -/* Functions for parsing the tokens into out structure */ -/* Defined at the end section of this file */ - -static void SetIconDirectory (char *path); -static void SetDefaultIcon (char *fname); -static void SetRootMenu (char *menu); -static void SetDefaultSysMenu (char *menu, int pos); -static void SetTrayIcon (char *fname); - -static void OpenMenu(char *menuname); -static void AddMenuLine(const char *name, MENUCOMMANDTYPE cmd, const char *param); -static void CloseMenu(void); - -static void OpenIcons(void); -static void AddIconLine(char *matchstr, char *iconfile); -static void CloseIcons(void); - -static void OpenStyles(void); -static void AddStyleLine(char *matchstr, unsigned long style); -static void CloseStyles(void); - -static void OpenSysMenu(void); -static void AddSysMenuLine(char *matchstr, char *menuname, int pos); -static void CloseSysMenu(void); - -static int yyerror (const char *s); - -extern char *yytext; -extern int yylineno; -extern int yylex(void); - -%} - -%union { - char *sVal; - unsigned long uVal; - int iVal; -} - -%token NEWLINE -%token MENU -%token LB -%token RB -%token ICONDIRECTORY -%token DEFAULTICON -%token ICONS -%token STYLES -%token TOPMOST -%token MAXIMIZE -%token MINIMIZE -%token BOTTOM -%token NOTITLE -%token OUTLINE -%token NOFRAME -%token DEFAULTSYSMENU -%token SYSMENU -%token ROOTMENU -%token SEPARATOR -%token ATSTART -%token ATEND -%token EXEC -%token ALWAYSONTOP -%token DEBUGOUTPUT "DEBUG" -%token RELOAD -%token TRAYICON -%token FORCEEXIT -%token SILENTEXIT - -%token <sVal> STRING -%type <uVal> group1 -%type <uVal> group2 -%type <uVal> stylecombo -%type <iVal> atspot - -%% - -input: /* empty */ - | input line - ; - -line: NEWLINE - | command - ; - - -newline_or_nada: - | NEWLINE newline_or_nada - ; - -command: defaulticon - | icondirectory - | menu - | icons - | styles - | sysmenu - | rootmenu - | defaultsysmenu - | debug - | trayicon - | forceexit - | silentexit - ; - -trayicon: TRAYICON STRING NEWLINE { SetTrayIcon($2); free($2); } - ; - -rootmenu: ROOTMENU STRING NEWLINE { SetRootMenu($2); free($2); } - ; - -defaultsysmenu: DEFAULTSYSMENU STRING atspot NEWLINE { SetDefaultSysMenu($2, $3); free($2); } - ; - -defaulticon: DEFAULTICON STRING NEWLINE { SetDefaultIcon($2); free($2); } - ; - -icondirectory: ICONDIRECTORY STRING NEWLINE { SetIconDirectory($2); free($2); } - ; - -menuline: SEPARATOR NEWLINE newline_or_nada { AddMenuLine("-", CMD_SEPARATOR, ""); } - | STRING ALWAYSONTOP NEWLINE newline_or_nada { AddMenuLine($1, CMD_ALWAYSONTOP, ""); free($1); } - | STRING EXEC STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_EXEC, $3); free($1); free($3); } - | STRING MENU STRING NEWLINE newline_or_nada { AddMenuLine($1, CMD_MENU, $3); free($1); free($3); } - | STRING RELOAD NEWLINE newline_or_nada { AddMenuLine($1, CMD_RELOAD, ""); free($1); } - ; - -menulist: menuline - | menuline menulist - ; - -menu: MENU STRING LB { OpenMenu($2); free($2); } newline_or_nada menulist RB {CloseMenu();} - ; - -iconline: STRING STRING NEWLINE newline_or_nada { AddIconLine($1, $2); free($1); free($2); } - ; - -iconlist: iconline - | iconline iconlist - ; - -icons: ICONS LB {OpenIcons();} newline_or_nada iconlist RB {CloseIcons();} - ; - -group1: TOPMOST { $$=STYLE_TOPMOST; } - | MAXIMIZE { $$=STYLE_MAXIMIZE; } - | MINIMIZE { $$=STYLE_MINIMIZE; } - | BOTTOM { $$=STYLE_BOTTOM; } - ; - -group2: NOTITLE { $$=STYLE_NOTITLE; } - | OUTLINE { $$=STYLE_OUTLINE; } - | NOFRAME { $$=STYLE_NOFRAME; } - ; - -stylecombo: group1 { $$=$1; } - | group2 { $$=$1; } - | group1 group2 { $$=$1|$2; } - | group2 group1 { $$=$1|$2; } - ; - -styleline: STRING stylecombo NEWLINE newline_or_nada { AddStyleLine($1, $2); free($1); } - ; - -stylelist: styleline - | styleline stylelist - ; - -styles: STYLES LB {OpenStyles();} newline_or_nada stylelist RB {CloseStyles();} - ; - -atspot: { $$=AT_END; } - | ATSTART { $$=AT_START; } - | ATEND { $$=AT_END; } - ; - -sysmenuline: STRING STRING atspot NEWLINE newline_or_nada { AddSysMenuLine($1, $2, $3); free($1); free($2); } - ; - -sysmenulist: sysmenuline - | sysmenuline sysmenulist - ; - -sysmenu: SYSMENU LB NEWLINE {OpenSysMenu();} newline_or_nada sysmenulist RB {CloseSysMenu();} - ; - -forceexit: FORCEEXIT NEWLINE { pref.fForceExit = TRUE; } - ; - -silentexit: SILENTEXIT NEWLINE { pref.fSilentExit = TRUE; } - ; - -debug: DEBUGOUTPUT STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($2); } - ; - - -%% -/* - * Errors in parsing abort and print log messages - */ -static int -yyerror (const char *s) -{ - ErrorF("LoadPreferences: %s line %d\n", s, yylineno); - return 1; -} - -/* Miscellaneous functions to store TOKENs into the structure */ -static void -SetIconDirectory (char *path) -{ - strncpy (pref.iconDirectory, path, PATH_MAX); - pref.iconDirectory[PATH_MAX] = 0; -} - -static void -SetDefaultIcon (char *fname) -{ - strncpy (pref.defaultIconName, fname, NAME_MAX); - pref.defaultIconName[NAME_MAX] = 0; -} - -static void -SetTrayIcon (char *fname) -{ - strncpy (pref.trayIconName, fname, NAME_MAX); - pref.trayIconName[NAME_MAX] = 0; -} - -static void -SetRootMenu (char *menuname) -{ - strncpy (pref.rootMenuName, menuname, MENU_MAX); - pref.rootMenuName[MENU_MAX] = 0; -} - -static void -SetDefaultSysMenu (char *menuname, int pos) -{ - strncpy (pref.defaultSysMenuName, menuname, MENU_MAX); - pref.defaultSysMenuName[MENU_MAX] = 0; - pref.defaultSysMenuPos = pos; -} - -static void -OpenMenu (char *menuname) -{ - if (menu.menuItem) free(menu.menuItem); - menu.menuItem = NULL; - strncpy(menu.menuName, menuname, MENU_MAX); - menu.menuName[MENU_MAX] = 0; - menu.menuItems = 0; -} - -static void -AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param) -{ - if (menu.menuItem==NULL) - menu.menuItem = malloc(sizeof(MENUITEM)); - else - menu.menuItem = realloc(menu.menuItem, sizeof(MENUITEM)*(menu.menuItems+1)); - - strncpy (menu.menuItem[menu.menuItems].text, text, MENU_MAX); - menu.menuItem[menu.menuItems].text[MENU_MAX] = 0; - - menu.menuItem[menu.menuItems].cmd = cmd; - - strncpy(menu.menuItem[menu.menuItems].param, param, PARAM_MAX); - menu.menuItem[menu.menuItems].param[PARAM_MAX] = 0; - - menu.menuItem[menu.menuItems].commandID = 0; - - menu.menuItems++; -} - -static void -CloseMenu (void) -{ - if (menu.menuItem==NULL || menu.menuItems==0) - { - ErrorF("LoadPreferences: Empty menu detected\n"); - return; - } - - if (pref.menuItems) - pref.menu = realloc (pref.menu, (pref.menuItems+1)*sizeof(MENUPARSED)); - else - pref.menu = malloc (sizeof(MENUPARSED)); - - memcpy (pref.menu+pref.menuItems, &menu, sizeof(MENUPARSED)); - pref.menuItems++; - - memset (&menu, 0, sizeof(MENUPARSED)); -} - -static void -OpenIcons (void) -{ - if (pref.icon != NULL) { - ErrorF("LoadPreferences: Redefining icon mappings\n"); - free(pref.icon); - pref.icon = NULL; - } - pref.iconItems = 0; -} - -static void -AddIconLine (char *matchstr, char *iconfile) -{ - if (pref.icon==NULL) - pref.icon = malloc(sizeof(ICONITEM)); - else - pref.icon = realloc(pref.icon, sizeof(ICONITEM)*(pref.iconItems+1)); - - strncpy(pref.icon[pref.iconItems].match, matchstr, MENU_MAX); - pref.icon[pref.iconItems].match[MENU_MAX] = 0; - - strncpy(pref.icon[pref.iconItems].iconFile, iconfile, PATH_MAX+NAME_MAX+1); - pref.icon[pref.iconItems].iconFile[PATH_MAX+NAME_MAX+1] = 0; - - pref.icon[pref.iconItems].hicon = 0; - - pref.iconItems++; -} - -static void -CloseIcons (void) -{ -} - -static void -OpenStyles (void) -{ - if (pref.style != NULL) { - ErrorF("LoadPreferences: Redefining window style\n"); - free(pref.style); - pref.style = NULL; - } - pref.styleItems = 0; -} - -static void -AddStyleLine (char *matchstr, unsigned long style) -{ - if (pref.style==NULL) - pref.style = malloc(sizeof(STYLEITEM)); - else - pref.style = realloc(pref.style, sizeof(STYLEITEM)*(pref.styleItems+1)); - - strncpy(pref.style[pref.styleItems].match, matchstr, MENU_MAX); - pref.style[pref.styleItems].match[MENU_MAX] = 0; - - pref.style[pref.styleItems].type = style; - - pref.styleItems++; -} - -static void -CloseStyles (void) -{ -} - -static void -OpenSysMenu (void) -{ - if (pref.sysMenu != NULL) { - ErrorF("LoadPreferences: Redefining system menu\n"); - free(pref.sysMenu); - pref.sysMenu = NULL; - } - pref.sysMenuItems = 0; -} - -static void -AddSysMenuLine (char *matchstr, char *menuname, int pos) -{ - if (pref.sysMenu==NULL) - pref.sysMenu = malloc(sizeof(SYSMENUITEM)); - else - pref.sysMenu = realloc(pref.sysMenu, sizeof(SYSMENUITEM)*(pref.sysMenuItems+1)); - - strncpy (pref.sysMenu[pref.sysMenuItems].match, matchstr, MENU_MAX); - pref.sysMenu[pref.sysMenuItems].match[MENU_MAX] = 0; - - strncpy (pref.sysMenu[pref.sysMenuItems].menuName, menuname, MENU_MAX); - pref.sysMenu[pref.sysMenuItems].menuName[MENU_MAX] = 0; - - pref.sysMenu[pref.sysMenuItems].menuPos = pos; - - pref.sysMenuItems++; -} - -static void -CloseSysMenu (void) -{ -} - diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c deleted file mode 100644 index 66023f335..000000000 --- a/hw/xwin/winprocarg.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* - -Copyright 1993, 1998 The Open Group -Copyright (C) Colin Harrison 2005-2008 - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from The Open Group. - -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#ifdef HAVE_SYS_UTSNAME_H -#include <sys/utsname.h> -#endif - -#include <../xfree86/common/xorgVersion.h> -#include "win.h" -#include "winconfig.h" -#include "winmsg.h" -#include "winmonitors.h" -#include "winprefs.h" - -#include "winclipboard/winclipboard.h" - -/* - * Function prototypes - */ - -void - winLogCommandLine(int argc, char *argv[]); - -void - winLogVersionInfo(void); - -/* - * Process arguments on the command line - */ - -static int iLastScreen = -1; -static winScreenInfo defaultScreenInfo; - -static void -winInitializeScreenDefaults(void) -{ - DWORD dwWidth, dwHeight; - static Bool fInitializedScreenDefaults = FALSE; - - /* Bail out early if default screen has already been initialized */ - if (fInitializedScreenDefaults) - return; - - /* Zero the memory used for storing the screen info */ - memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); - - /* Get default width and height */ - /* - * NOTE: These defaults will cause the window to cover only - * the primary monitor in the case that we have multiple monitors. - */ - dwWidth = GetSystemMetrics(SM_CXSCREEN); - dwHeight = GetSystemMetrics(SM_CYSCREEN); - - winErrorFVerb(2, - "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); - - winErrorFVerb(2, - "winInitializeScreenDefaults - native DPI x %d y %d\n", - dpiX, dpiY); - - monitorResolution = dpiY; - ReleaseDC(NULL, hdc); - } - else { - winErrorFVerb(1, - "winInitializeScreenDefaults - 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; -#ifdef XWIN_EMULATEPSEUDO - defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; -#endif - defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; - defaultScreenInfo.pfb = NULL; - defaultScreenInfo.fFullScreen = FALSE; - defaultScreenInfo.fDecoration = TRUE; - defaultScreenInfo.fRootless = FALSE; - defaultScreenInfo.fMultiWindow = FALSE; - defaultScreenInfo.fCompositeWM = TRUE; - defaultScreenInfo.fMultiMonitorOverride = FALSE; - defaultScreenInfo.fMultipleMonitors = FALSE; - defaultScreenInfo.fLessPointer = FALSE; - defaultScreenInfo.iResizeMode = resizeDefault; - 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; - defaultScreenInfo.hIcon = (HICON) - LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, - GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0); - defaultScreenInfo.hIconSm = (HICON) - LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON, - GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), - LR_DEFAULTSIZE); - - /* Note that the default screen has been initialized */ - fInitializedScreenDefaults = TRUE; -} - -static void -winInitializeScreen(int i) -{ - winErrorFVerb(3, "winInitializeScreen - %d\n", i); - - /* Initialize default screen values, if needed */ - winInitializeScreenDefaults(); - - /* Copy the default screen info */ - g_ScreenInfo[i] = defaultScreenInfo; - - /* Set the screen number */ - g_ScreenInfo[i].dwScreen = i; -} - -void -winInitializeScreens(int maxscreens) -{ - int i; - - winErrorFVerb(3, "winInitializeScreens - %i\n", maxscreens); - - if (maxscreens > g_iNumScreens) { - /* Reallocate the memory for DDX-specific screen info */ - g_ScreenInfo = - realloc(g_ScreenInfo, maxscreens * sizeof(winScreenInfo)); - - /* Set default values for any new screens */ - for (i = g_iNumScreens; i < maxscreens; i++) - winInitializeScreen(i); - - /* Keep a count of the number of screens */ - g_iNumScreens = maxscreens; - } -} - -/* See Porting Layer Definition - p. 57 */ -/* - * INPUT - * argv: pointer to an array of null-terminated strings, one for - * each token in the X Server command line; the first token - * is 'XWin.exe', or similar. - * argc: a count of the number of tokens stored in argv. - * i: a zero-based index into argv indicating the current token being - * processed. - * - * OUTPUT - * return: return the number of tokens processed correctly. - * - * NOTE - * When looking for n tokens, check that i + n is less than argc. Or, - * you may check if i is greater than or equal to argc, in which case - * you should display the UseMsg () and return 0. - */ - -/* Check if enough arguments are given for the option */ -#define CHECK_ARGS(count) if (i + count >= argc) { UseMsg (); return 0; } - -/* Compare the current option with the string. */ -#define IS_OPTION(name) (strcmp (argv[i], name) == 0) - -int -ddxProcessArgument(int argc, char *argv[], int i) -{ - static Bool s_fBeenHere = FALSE; - winScreenInfo *screenInfoPtr = NULL; - - /* Initialize once */ - if (!s_fBeenHere) { -#ifdef DDXOSVERRORF - /* - * This initialises our hook into VErrorF () for catching log messages - * that are generated before OsInit () is called. - */ - OsVendorVErrorFProc = OsVendorVErrorF; -#endif - - s_fBeenHere = TRUE; - - /* Initialize only if option is not -help */ - if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") && - !IS_OPTION("-version") && !IS_OPTION("--version")) { - - /* Log the version information */ - winLogVersionInfo(); - - /* Log the command line */ - winLogCommandLine(argc, argv); - - /* - * Initialize default screen settings. We have to do this before - * OsVendorInit () gets called, otherwise we will overwrite - * settings changed by parameters such as -fullscreen, etc. - */ - winErrorFVerb(3, "ddxProcessArgument - Initializing default " - "screens\n"); - winInitializeScreenDefaults(); - } - } - -#if CYGDEBUG - winDebug("ddxProcessArgument - arg: %s\n", argv[i]); -#endif - - /* - * Look for the '-help' and similar options - */ - if (IS_OPTION("-help") || IS_OPTION("-h") || IS_OPTION("--help")) { - /* Reset logfile. We don't need that helpmessage in the logfile */ - g_pszLogFile = NULL; - g_fNoHelpMessageBox = TRUE; - UseMsg(); - exit(0); - return 1; - } - - if (IS_OPTION("-version") || IS_OPTION("--version")) { - /* Reset logfile. We don't need that versioninfo in the logfile */ - g_pszLogFile = NULL; - winLogVersionInfo(); - exit(0); - return 1; - } - - /* - * Look for the '-screen scr_num [width height]' argument - */ - if (IS_OPTION("-screen")) { - int iArgsProcessed = 1; - int nScreenNum; - int iWidth, iHeight, iX, iY; - int iMonitor; - -#if CYGDEBUG - winDebug("ddxProcessArgument - screen - argc: %d i: %d\n", argc, i); -#endif - - /* Display the usage message if the argument is malformed */ - if (i + 1 >= argc) { - return 0; - } - - /* Grab screen number */ - nScreenNum = atoi(argv[i + 1]); - - /* Validate the specified screen number */ - if (nScreenNum < 0) { - ErrorF("ddxProcessArgument - screen - Invalid screen number %d\n", - nScreenNum); - UseMsg(); - return 0; - } - - /* - Initialize default values for any new screens - - Note that default values can't change after a -screen option is - seen, so it's safe to do this for each screen as it is introduced - */ - winInitializeScreens(nScreenNum + 1); - - /* look for @m where m is monitor number */ - if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) { - struct GetMonitorInfoData data; - - if (QueryMonitor(iMonitor, &data)) { - winErrorFVerb(2, - "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); - exit(1); - return 0; - } - } - - /* Look for 'WxD' or 'W D' */ - else if (i + 2 < argc - && 2 == sscanf(argv[i + 2], "%dx%d", - (int *) &iWidth, (int *) &iHeight)) { - winErrorFVerb(2, - "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)) { - winErrorFVerb(2, - "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)) { - 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); - exit(1); - 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)) { - winErrorFVerb(2, - "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); - exit(1); - return 0; - } - } - } - else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth) - && 1 == sscanf(argv[i + 3], "%d", (int *) &iHeight)) { - winErrorFVerb(2, - "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)) { - winErrorFVerb(2, - "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 { - winErrorFVerb(2, - "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 explicitly specified by the user */ - g_ScreenInfo[nScreenNum].fExplicitScreen = TRUE; - - /* - * Keep track of the last screen number seen, as parameters seen - * before a screen number apply to all screens, whereas parameters - * seen after a screen number apply to that screen number only. - */ - iLastScreen = nScreenNum; - - return iArgsProcessed; - } - - /* - * Is this parameter attached to a screen or global? - * - * If the parameter is for all screens (appears before - * any -screen option), store it in the default screen - * info - * - * If the parameter is for a single screen (appears - * after a -screen option), store it in the screen info - * for that screen - * - */ - if (iLastScreen == -1) { - screenInfoPtr = &defaultScreenInfo; - } - else { - screenInfoPtr = &(g_ScreenInfo[iLastScreen]); - } - - /* - * Look for the '-engine n' argument - */ - if (IS_OPTION("-engine")) { - DWORD dwEngine = 0; - CARD8 c8OnBits = 0; - - /* Display the usage message if the argument is malformed */ - if (++i >= argc) { - UseMsg(); - return 0; - } - - /* Grab the argument */ - dwEngine = atoi(argv[i]); - - /* Count the one bits in the engine argument */ - c8OnBits = winCountBits(dwEngine); - - /* Argument should only have a single bit on */ - if (c8OnBits != 1) { - UseMsg(); - return 0; - } - - screenInfoPtr->dwEnginePreferred = dwEngine; - - /* Indicate that we have processed the argument */ - return 2; - } - - /* - * Look for the '-fullscreen' argument - */ - if (IS_OPTION("-fullscreen")) { - if (!screenInfoPtr->fMultiMonitorOverride) - screenInfoPtr->fMultipleMonitors = FALSE; - screenInfoPtr->fFullScreen = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-lesspointer' argument - */ - if (IS_OPTION("-lesspointer")) { - screenInfoPtr->fLessPointer = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-nodecoration' argument - */ - if (IS_OPTION("-nodecoration")) { - if (!screenInfoPtr->fMultiMonitorOverride) - screenInfoPtr->fMultipleMonitors = FALSE; - screenInfoPtr->fDecoration = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-rootless' argument - */ - if (IS_OPTION("-rootless")) { - if (!screenInfoPtr->fMultiMonitorOverride) - screenInfoPtr->fMultipleMonitors = FALSE; - screenInfoPtr->fRootless = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-multiwindow' argument - */ - if (IS_OPTION("-multiwindow")) { - if (!screenInfoPtr->fMultiMonitorOverride) - screenInfoPtr->fMultipleMonitors = TRUE; - screenInfoPtr->fMultiWindow = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-compositewm' argument - */ - if (IS_OPTION("-compositewm")) { - screenInfoPtr->fCompositeWM = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - /* - * Look for the '-nocompositewm' argument - */ - if (IS_OPTION("-nocompositewm")) { - screenInfoPtr->fCompositeWM = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-compositealpha' argument - */ - if (IS_OPTION("-compositealpha")) { - g_fCompositeAlpha = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - /* - * Look for the '-nocompositealpha' argument - */ - if (IS_OPTION("-nocompositealpha")) { - g_fCompositeAlpha = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-multiplemonitors' argument - */ - if (IS_OPTION("-multiplemonitors") - || IS_OPTION("-multimonitors")) { - screenInfoPtr->fMultiMonitorOverride = TRUE; - screenInfoPtr->fMultipleMonitors = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-nomultiplemonitors' argument - */ - if (IS_OPTION("-nomultiplemonitors") - || IS_OPTION("-nomultimonitors")) { - screenInfoPtr->fMultiMonitorOverride = TRUE; - screenInfoPtr->fMultipleMonitors = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-scrollbars' argument - */ - if (IS_OPTION("-scrollbars")) { - - screenInfoPtr->iResizeMode = resizeWithScrollbars; - - /* 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; - - if (IS_OPTION("-resize")) - mode = resizeWithRandr; - else if (IS_OPTION("-noresize")) - mode = resizeNotAllowed; - 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 = resizeNotAllowed; - 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; - } - - screenInfoPtr->iResizeMode = mode; - - /* 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; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-primary' argument - */ - if (IS_OPTION("-primary")) { - fPrimarySelection = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-noprimary' argument - */ - if (IS_OPTION("-noprimary")) { - fPrimarySelection = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-ignoreinput' argument - */ - if (IS_OPTION("-ignoreinput")) { - screenInfoPtr->fIgnoreInput = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-emulate3buttons' argument - */ - if (IS_OPTION("-emulate3buttons")) { - int iArgsProcessed = 1; - int iE3BTimeout = WIN_DEFAULT_E3B_TIME; - - /* Grab the optional timeout value */ - if (i + 1 < argc && 1 == sscanf(argv[i + 1], "%d", &iE3BTimeout)) { - /* Indicate that we have processed the next argument */ - iArgsProcessed++; - } - else { - /* - * sscanf () won't modify iE3BTimeout if it doesn't find - * the specified format; however, I want to be explicit - * about setting the default timeout in such cases to - * prevent some programs (me) from getting confused. - */ - iE3BTimeout = WIN_DEFAULT_E3B_TIME; - } - - screenInfoPtr->iE3BTimeout = iE3BTimeout; - - /* Indicate that we have processed this argument */ - return iArgsProcessed; - } - - /* - * Look for the '-noemulate3buttons' argument - */ - if (IS_OPTION("-noemulate3buttons")) { - screenInfoPtr->iE3BTimeout = WIN_E3B_OFF; - - /* 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 '-refresh n' argument - */ - if (IS_OPTION("-refresh")) { - DWORD dwRefreshRate = 0; - - /* Display the usage message if the argument is malformed */ - if (++i >= argc) { - UseMsg(); - return 0; - } - - /* Grab the argument */ - dwRefreshRate = atoi(argv[i]); - - screenInfoPtr->dwRefreshRate = dwRefreshRate; - - /* Indicate that we have processed the argument */ - return 2; - } - - /* - * Look for the '-clipupdates num_boxes' argument - */ - if (IS_OPTION("-clipupdates")) { - DWORD dwNumBoxes = 0; - - /* Display the usage message if the argument is malformed */ - if (++i >= argc) { - UseMsg(); - return 0; - } - - /* Grab the argument */ - dwNumBoxes = atoi(argv[i]); - - screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; - - /* Indicate that we have processed the argument */ - return 2; - } - -#ifdef XWIN_EMULATEPSEUDO - /* - * Look for the '-emulatepseudo' argument - */ - if (IS_OPTION("-emulatepseudo")) { - screenInfoPtr->fEmulatePseudo = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } -#endif - - /* - * Look for the '-nowinkill' argument - */ - if (IS_OPTION("-nowinkill")) { - screenInfoPtr->fUseWinKillKey = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-winkill' argument - */ - if (IS_OPTION("-winkill")) { - screenInfoPtr->fUseWinKillKey = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-nounixkill' argument - */ - if (IS_OPTION("-nounixkill")) { - screenInfoPtr->fUseUnixKillKey = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-unixkill' argument - */ - if (IS_OPTION("-unixkill")) { - screenInfoPtr->fUseUnixKillKey = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-notrayicon' argument - */ - if (IS_OPTION("-notrayicon")) { - screenInfoPtr->fNoTrayIcon = TRUE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-trayicon' argument - */ - if (IS_OPTION("-trayicon")) { - screenInfoPtr->fNoTrayIcon = FALSE; - - /* Indicate that we have processed this argument */ - return 1; - } - - /* - * Look for the '-fp' argument - */ - if (IS_OPTION("-fp")) { - CHECK_ARGS(1); - g_cmdline.fontPath = argv[++i]; - return 0; /* Let DIX parse this again */ - } - - /* - * Look for the '-query' argument - */ - if (IS_OPTION("-query")) { - CHECK_ARGS(1); - g_fXdmcpEnabled = TRUE; - g_pszQueryHost = argv[++i]; - return 0; /* Let DIX parse this again */ - } - - /* - * Look for the '-auth' argument - */ - if (IS_OPTION("-auth")) { - g_fAuthEnabled = TRUE; - return 0; /* Let DIX parse this again */ - } - - /* - * Look for the '-indirect' or '-broadcast' arguments - */ - if (IS_OPTION("-indirect") - || IS_OPTION("-broadcast")) { - g_fXdmcpEnabled = TRUE; - return 0; /* Let DIX parse this again */ - } - - /* - * Look for the '-config' argument - */ - if (IS_OPTION("-config") - || IS_OPTION("-xf86config")) { - CHECK_ARGS(1); -#ifdef XWIN_XF86CONFIG - g_cmdline.configFile = argv[++i]; -#else - winMessageBoxF("The %s option is not supported in this " - "release.\n" - "Ignoring this option and continuing.\n", - MB_ICONINFORMATION, argv[i]); -#endif - return 2; - } - - /* - * Look for the '-configdir' argument - */ - if (IS_OPTION("-configdir")) { - CHECK_ARGS(1); -#ifdef XWIN_XF86CONFIG - g_cmdline.configDir = argv[++i]; -#else - winMessageBoxF("The %s option is not supported in this " - "release.\n" - "Ignoring this option and continuing.\n", - MB_ICONINFORMATION, argv[i]); -#endif - return 2; - } - - /* - * Look for the '-keyboard' argument - */ - if (IS_OPTION("-keyboard")) { -#ifdef XWIN_XF86CONFIG - CHECK_ARGS(1); - g_cmdline.keyboard = argv[++i]; -#else - winMessageBoxF("The -keyboard option is not supported in this " - "release.\n" - "Ignoring this option and continuing.\n", - MB_ICONINFORMATION); -#endif - return 2; - } - - /* - * Look for the '-logfile' argument - */ - if (IS_OPTION("-logfile")) { - CHECK_ARGS(1); - g_pszLogFile = argv[++i]; -#ifdef RELOCATE_PROJECTROOT - g_fLogFileChanged = TRUE; -#endif - return 2; - } - - /* - * Look for the '-logverbose' argument - */ - if (IS_OPTION("-logverbose")) { - CHECK_ARGS(1); - g_iLogVerbose = atoi(argv[++i]); - return 2; - } - - if (IS_OPTION("-xkbrules")) { - CHECK_ARGS(1); - g_cmdline.xkbRules = argv[++i]; - return 2; - } - if (IS_OPTION("-xkbmodel")) { - CHECK_ARGS(1); - g_cmdline.xkbModel = argv[++i]; - return 2; - } - if (IS_OPTION("-xkblayout")) { - CHECK_ARGS(1); - g_cmdline.xkbLayout = argv[++i]; - return 2; - } - if (IS_OPTION("-xkbvariant")) { - CHECK_ARGS(1); - g_cmdline.xkbVariant = argv[++i]; - return 2; - } - if (IS_OPTION("-xkboptions")) { - CHECK_ARGS(1); - g_cmdline.xkbOptions = argv[++i]; - return 2; - } - - if (IS_OPTION("-keyhook")) { - g_fKeyboardHookLL = TRUE; - return 1; - } - - if (IS_OPTION("-nokeyhook")) { - g_fKeyboardHookLL = FALSE; - return 1; - } - - if (IS_OPTION("-swcursor")) { - g_fSoftwareCursor = TRUE; - return 1; - } - - if (IS_OPTION("-wgl")) { - g_fNativeGl = TRUE; - return 1; - } - - if (IS_OPTION("-nowgl")) { - g_fNativeGl = FALSE; - return 1; - } - - if (IS_OPTION("-hostintitle")) { - g_fHostInTitle = TRUE; - return 1; - } - - if (IS_OPTION("-nohostintitle")) { - g_fHostInTitle = FALSE; - return 1; - } - - if (IS_OPTION("-icon")) { - char *iconspec; - CHECK_ARGS(1); - iconspec = argv[++i]; - screenInfoPtr->hIcon = LoadImageComma(iconspec, NULL, - GetSystemMetrics(SM_CXICON), - GetSystemMetrics(SM_CYICON), - 0); - screenInfoPtr->hIconSm = LoadImageComma(iconspec, NULL, - GetSystemMetrics(SM_CXSMICON), - GetSystemMetrics(SM_CYSMICON), - LR_DEFAULTSIZE); - if ((screenInfoPtr->hIcon == NULL) || - (screenInfoPtr->hIconSm == NULL)) { - ErrorF("ddxProcessArgument - icon - Invalid icon specification %s\n", - iconspec); - exit(1); - } - - /* Indicate that we have processed the argument */ - return 2; - } - - return 0; -} - -/* - * winLogCommandLine - Write entire command line to the log file - */ - -void -winLogCommandLine(int argc, char *argv[]) -{ - int i; - int iSize = 0; - int iCurrLen = 0; - -#define CHARS_PER_LINE 60 - - /* Bail if command line has already been logged */ - if (g_pszCommandLine) - return; - - /* Count how much memory is needed for concatenated command line */ - for (i = 0, iCurrLen = 0; i < argc; ++i) - if (argv[i]) { - /* Adds two characters for lines that overflow */ - if ((strlen(argv[i]) < CHARS_PER_LINE - && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) - || strlen(argv[i]) > CHARS_PER_LINE) { - iCurrLen = 0; - iSize += 2; - } - - /* Add space for item and trailing space */ - iSize += strlen(argv[i]) + 1; - - /* Update current line length */ - iCurrLen += strlen(argv[i]); - } - - /* Allocate memory for concatenated command line */ - g_pszCommandLine = malloc(iSize + 1); - if (!g_pszCommandLine) - FatalError("winLogCommandLine - Could not allocate memory for " - "command line string. Exiting.\n"); - - /* Set first character to concatenated command line to null */ - g_pszCommandLine[0] = '\0'; - - /* Loop through all args */ - for (i = 0, iCurrLen = 0; i < argc; ++i) { - /* Add a character for lines that overflow */ - if ((strlen(argv[i]) < CHARS_PER_LINE - && iCurrLen + strlen(argv[i]) > CHARS_PER_LINE) - || strlen(argv[i]) > CHARS_PER_LINE) { - iCurrLen = 0; - - /* Add line break if it fits */ - strncat(g_pszCommandLine, "\n ", iSize - strlen(g_pszCommandLine)); - } - - strncat(g_pszCommandLine, argv[i], iSize - strlen(g_pszCommandLine)); - strncat(g_pszCommandLine, " ", iSize - strlen(g_pszCommandLine)); - - /* Save new line length */ - iCurrLen += strlen(argv[i]); - } - - ErrorF("XWin was started with the following command line:\n\n" - "%s\n\n", g_pszCommandLine); -} - -/* - * winLogVersionInfo - Log version information - */ - -void -winLogVersionInfo(void) -{ - static Bool s_fBeenHere = FALSE; - - if (s_fBeenHere) - return; - s_fBeenHere = TRUE; - - ErrorF("Welcome to the XWin X Server\n"); - ErrorF("Vendor: %s\n", XVENDORNAME); - ErrorF("Release: %d.%d.%d.%d\n", XORG_VERSION_MAJOR, - XORG_VERSION_MINOR, XORG_VERSION_PATCH, XORG_VERSION_SNAP); -#ifdef HAVE_SYS_UTSNAME_H - { - struct utsname name; - - if (uname(&name) >= 0) { - ErrorF("OS: %s %s %s %s %s\n", name.sysname, name.nodename, - name.release, name.version, name.machine); - } - } -#endif - winOS(); - if (strlen(BUILDERSTRING)) - ErrorF("%s\n", BUILDERSTRING); - ErrorF("Contact: %s\n", BUILDERADDR); - ErrorF("\n"); -} diff --git a/hw/xwin/winrandr.c b/hw/xwin/winrandr.c deleted file mode 100644 index 038d63bde..000000000 --- a/hw/xwin/winrandr.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. - *Copyright (C) 2009-2010 Jon TURNEY - * - *Permission is hereby granted, free of charge, to any person obtaining - *a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the author(s) - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the author(s) - * - * Authors: Harold L Hunt II - * Jon TURNEY - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -/* - * Answer queries about the RandR features supported. - */ - -static Bool -winRandRGetInfo(ScreenPtr pScreen, Rotation * pRotations) -{ - winDebug("winRandRGetInfo ()\n"); - - /* Don't support rotations */ - *pRotations = RR_Rotate_0; - - return TRUE; -} - -static void -winRandRUpdateMode(ScreenPtr pScreen, RROutputPtr output) -{ - /* Delete previous mode */ - if (output->modes[0]) - { - RRModeDestroy(output->modes[0]); - RRModeDestroy(output->crtc->mode); - } - - /* Register current mode */ - { - xRRModeInfo modeInfo; - RRModePtr mode; - char name[100]; - - memset(&modeInfo, '\0', sizeof(modeInfo)); - snprintf(name, sizeof(name), "%dx%d", pScreen->width, pScreen->height); - - modeInfo.width = pScreen->width; - modeInfo.height = pScreen->height; - modeInfo.hTotal = pScreen->width; - modeInfo.vTotal = pScreen->height; - modeInfo.dotClock = 0; - modeInfo.nameLength = strlen(name); - mode = RRModeGet(&modeInfo, name); - - output->modes[0] = mode; - output->numModes = 1; - - mode = RRModeGet(&modeInfo, name); - output->crtc->mode = mode; - } -} - -/* - -*/ -void -winDoRandRScreenSetSize(ScreenPtr pScreen, - CARD16 width, - CARD16 height, CARD32 mmWidth, CARD32 mmHeight) -{ - rrScrPrivPtr pRRScrPriv; - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - WindowPtr pRoot = pScreen->root; - - /* Ignore changes which do nothing */ - if ((pScreen->width == width) && (pScreen->height == height) && - (pScreen->mmWidth == mmWidth) && (pScreen->mmHeight == mmHeight)) - return; - - // Prevent screen updates while we change things around - SetRootClip(pScreen, ROOT_CLIP_NONE); - - /* Update the screen size as requested */ - pScreenInfo->dwWidth = width; - pScreenInfo->dwHeight = height; - - /* Reallocate the framebuffer used by the drawing engine */ - (*pScreenPriv->pwinFreeFB) (pScreen); - if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) { - ErrorF("winDoRandRScreenSetSize - Could not reallocate framebuffer\n"); - } - - pScreen->width = width; - pScreen->height = height; - pScreen->mmWidth = mmWidth; - pScreen->mmHeight = mmHeight; - - /* Update the screen pixmap to point to the new framebuffer */ - winUpdateFBPointer(pScreen, pScreenInfo->pfb); - - // pScreen->devPrivate == pScreen->GetScreenPixmap(screen) ? - // resize the root window - //pScreen->ResizeWindow(pRoot, 0, 0, width, height, NULL); - // does this emit a ConfigureNotify?? - - // Restore the ability to update screen, now with new dimensions - SetRootClip(pScreen, ROOT_CLIP_FULL); - - // and arrange for it to be repainted - pScreen->PaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); - - // Set mode to current display size - pRRScrPriv = rrGetScrPriv(pScreen); - winRandRUpdateMode(pScreen, pRRScrPriv->primaryOutput); - - /* Indicate that a screen size change took place */ - RRScreenSizeNotify(pScreen); -} - -/* - * Respond to resize request - */ -static - Bool -winRandRScreenSetSize(ScreenPtr pScreen, - CARD16 width, - CARD16 height, CARD32 mmWidth, CARD32 mmHeight) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - winDebug("winRandRScreenSetSize ()\n"); - - /* - It doesn't currently make sense to allow resize in fullscreen mode - (we'd actually have to list the supported resolutions) - */ - if (pScreenInfo->fFullScreen) { - ErrorF - ("winRandRScreenSetSize - resize not supported in fullscreen mode\n"); - return FALSE; - } - - /* - Client resize requests aren't allowed in rootless modes, even if - the X screen is monitor or virtual desktop size, we'd need to - resize the native display size - */ - if (FALSE - || pScreenInfo->fRootless - || pScreenInfo->fMultiWindow - ) { - ErrorF - ("winRandRScreenSetSize - resize not supported in rootless modes\n"); - return FALSE; - } - - winDoRandRScreenSetSize(pScreen, width, height, mmWidth, mmHeight); - - /* Cause the native window for the screen to resize itself */ - { - DWORD dwStyle, dwExStyle; - RECT rcClient; - - rcClient.left = 0; - rcClient.top = 0; - rcClient.right = width; - rcClient.bottom = height; - - ErrorF("winRandRScreenSetSize new client area w: %d h: %d\n", width, - height); - - /* Get the Windows window style and extended style */ - dwExStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_EXSTYLE); - dwStyle = GetWindowLongPtr(pScreenPriv->hwndScreen, GWL_STYLE); - - /* - * Calculate the window size needed for the given client area - * adjusting for any decorations it will have - */ - AdjustWindowRectEx(&rcClient, dwStyle, FALSE, dwExStyle); - - ErrorF("winRandRScreenSetSize new window area w: %d h: %d\n", - (int)(rcClient.right - rcClient.left), - (int)(rcClient.bottom - rcClient.top)); - - SetWindowPos(pScreenPriv->hwndScreen, NULL, - 0, 0, rcClient.right - rcClient.left, - rcClient.bottom - rcClient.top, SWP_NOZORDER | SWP_NOMOVE); - } - - return TRUE; -} - -/* - * Initialize the RandR layer. - */ - -Bool -winRandRInit(ScreenPtr pScreen) -{ - rrScrPrivPtr pRRScrPriv; - - winDebug("winRandRInit ()\n"); - - if (!RRScreenInit(pScreen)) { - ErrorF("winRandRInit () - RRScreenInit () failed\n"); - return FALSE; - } - - /* Set some RandR function pointers */ - pRRScrPriv = rrGetScrPriv(pScreen); - pRRScrPriv->rrGetInfo = winRandRGetInfo; - pRRScrPriv->rrSetConfig = NULL; - pRRScrPriv->rrScreenSetSize = winRandRScreenSetSize; - pRRScrPriv->rrCrtcSet = NULL; - pRRScrPriv->rrCrtcSetGamma = NULL; - - /* Create a CRTC and an output for the screen, and hook them together */ - { - RRCrtcPtr crtc; - RROutputPtr output; - - crtc = RRCrtcCreate(pScreen, NULL); - if (!crtc) - return FALSE; - - crtc->rotations = RR_Rotate_0; - - output = RROutputCreate(pScreen, "default", 7, NULL); - if (!output) - return FALSE; - - RROutputSetCrtcs(output, &crtc, 1); - RROutputSetConnection(output, RR_Connected); - RROutputSetSubpixelOrder(output, PictureGetSubpixelOrder(pScreen)); - - output->crtc = crtc; - - /* Set crtc outputs (should use RRCrtcNotify?) */ - crtc->outputs = malloc(sizeof(RROutputPtr)); - crtc->outputs[0] = output; - crtc->numOutputs = 1; - - pRRScrPriv->primaryOutput = output; - - /* Ensure we have space for exactly one mode */ - output->modes = malloc(sizeof(RRModePtr)); - output->modes[0] = NULL; - - /* Set mode to current display size */ - winRandRUpdateMode(pScreen, output); - - /* Make up some physical dimensions */ - output->mmWidth = (pScreen->width * 25.4)/monitorResolution; - output->mmHeight = (pScreen->height * 25.4)/monitorResolution; - - /* Allocate and make up a (fixed, linear) gamma ramp */ - { - int i; - RRCrtcGammaSetSize(crtc, 256); - for (i = 0; i < crtc->gammaSize; i++) { - crtc->gammaRed[i] = i << 8; - crtc->gammaBlue[i] = i << 8; - crtc->gammaGreen[i] = i << 8; - } - } - } - - /* - The screen doesn't have to be limited to the actual - monitor size (we can have scrollbars :-), so set the - upper limit to the maximum coordinates X11 can use. - */ - RRScreenSetSizeRange(pScreen, 0, 0, 32768, 32768); - - return TRUE; -} diff --git a/hw/xwin/winresource.h b/hw/xwin/winresource.h deleted file mode 100644 index 37e92ce61..000000000 --- a/hw/xwin/winresource.h +++ /dev/null @@ -1,50 +0,0 @@ -#if !defined(WINRESOURCE_H) -#define WINRESOURCE_H -/* - *Copyright (C) 2002-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 - */ - -/* - * Local defines - */ - -#define IDC_STATIC -1 -#define IDI_XWIN 101 -#define IDM_TRAYICON_MENU 103 -#define IDC_CLIENTS_CONNECTED 104 - -#define ID_APP_EXIT 200 -#define ID_APP_HIDE_ROOT 201 -#define ID_APP_ALWAYS_ON_TOP 202 -#define ID_APP_ABOUT 203 -#define ID_APP_MONITOR_PRIMARY 204 - -#define ID_ABOUT_WEBSITE 303 - -#endif diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c deleted file mode 100644 index ae6bc12a6..000000000 --- a/hw/xwin/winscrinit.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - * Kensuke Matsuzaki - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include "winmsg.h" - -/* - * Determine what type of screen we are initializing - * and call the appropriate procedure to initialize - * that type of screen. - */ - -Bool -winScreenInit(ScreenPtr pScreen, int argc, char **argv) -{ - winScreenInfoPtr pScreenInfo = &g_ScreenInfo[pScreen->myNum]; - winPrivScreenPtr pScreenPriv; - HDC hdc; - DWORD dwInitialBPP; - -#if CYGDEBUG || YES - winDebug("winScreenInit - dwWidth: %u dwHeight: %u\n", - (unsigned int)pScreenInfo->dwWidth, (unsigned int)pScreenInfo->dwHeight); -#endif - - /* Allocate privates for this screen */ - if (!winAllocatePrivates(pScreen)) { - ErrorF("winScreenInit - Couldn't allocate screen privates\n"); - return FALSE; - } - - /* Get a pointer to the privates structure that was allocated */ - pScreenPriv = winGetScreenPriv(pScreen); - - /* Save a pointer to this screen in the screen info structure */ - pScreenInfo->pScreen = pScreen; - - /* Save a pointer to the screen info in the screen privates structure */ - /* This allows us to get back to the screen info from a screen pointer */ - pScreenPriv->pScreenInfo = pScreenInfo; - - /* - * Determine which engine to use. - * - * NOTE: This is done once per screen because each screen possibly has - * a preferred engine specified on the command line. - */ - if (!winSetEngine(pScreen)) { - ErrorF("winScreenInit - winSetEngine () failed\n"); - return FALSE; - } - - /* Horribly misnamed function: Allow engine to adjust BPP for screen */ - dwInitialBPP = pScreenInfo->dwBPP; - - if (!(*pScreenPriv->pwinAdjustVideoMode) (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 */ - ErrorF - ("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 */ - ErrorF - ("winScreenInit - Command line depth of %d bpp overridden by engine, using %d bpp\n", - (int) dwInitialBPP, (int) pScreenInfo->dwBPP); - } - else { - ErrorF("winScreenInit - Using command line depth of %d bpp\n", - (int) pScreenInfo->dwBPP); - } - - /* Check for supported display depth */ - if (!(WIN_SUPPORTED_BPPS & (1 << (pScreenInfo->dwBPP - 1)))) { - ErrorF("winScreenInit - Unsupported display depth: %d\n" - "Change your Windows display depth to 15, 16, 24, or 32 bits " - "per pixel.\n", (int) pScreenInfo->dwBPP); - ErrorF("winScreenInit - Supported depths: %08x\n", WIN_SUPPORTED_BPPS); -#if WIN_CHECK_DEPTH - return FALSE; -#endif - } - - /* - * Check that all monitors have the same display depth if we are using - * multiple monitors - */ - if (pScreenInfo->fMultipleMonitors - && !GetSystemMetrics(SM_SAMEDISPLAYFORMAT)) { - ErrorF("winScreenInit - Monitors do not all have same pixel format / " - "display depth.\n"); - if (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI) { - ErrorF - ("winScreenInit - Performance may suffer off primary display.\n"); - } - else { - ErrorF("winScreenInit - Using primary display only.\n"); - pScreenInfo->fMultipleMonitors = FALSE; - } - } - - /* Create display window */ - if (!(*pScreenPriv->pwinCreateBoundingWindow) (pScreen)) { - ErrorF("winScreenInit - pwinCreateBoundingWindow () " "failed\n"); - return FALSE; - } - - /* Get a device context */ - hdc = GetDC(pScreenPriv->hwndScreen); - - /* Are we using multiple monitors? */ - if (pScreenInfo->fMultipleMonitors) { - /* - * In this case, some of the defaults set in - * winInitializeScreenDefaults() are not correct ... - */ - if (!pScreenInfo->fUserGaveHeightAndWidth) { - pScreenInfo->dwWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); - pScreenInfo->dwHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); - } - } - - /* Release the device context */ - ReleaseDC(pScreenPriv->hwndScreen, hdc); - - /* Clear the visuals list */ - miClearVisualTypes(); - - /* Call the engine dependent screen initialization procedure */ - if (!((*pScreenPriv->pwinFinishScreenInit) (pScreen->myNum, pScreen, argc, argv))) { - ErrorF("winScreenInit - winFinishScreenInit () failed\n"); - - /* call the engine dependent screen close procedure to clean up from a failure */ - pScreenPriv->pwinCloseScreen(pScreen); - - return FALSE; - } - - if (!g_fSoftwareCursor) - winInitCursor(pScreen); - else - winErrorFVerb(2, "winScreenInit - Using software cursor\n"); - - if (!noPanoramiXExtension) { - /* - 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); - - ErrorF("Screen %d added at virtual desktop coordinate (%d,%d).\n", - pScreen->myNum, pScreen->x, pScreen->y); - } - -#if CYGDEBUG || YES - winDebug("winScreenInit - returning\n"); -#endif - - return TRUE; -} - -static Bool -winCreateScreenResources(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - Bool result; - - result = pScreenPriv->pwinCreateScreenResources(pScreen); - - /* Now the screen bitmap has been wrapped in a pixmap, - add that to the Shadow framebuffer */ - if (!shadowAdd(pScreen, pScreen->devPrivate, - pScreenPriv->pwinShadowUpdate, NULL, 0, 0)) { - ErrorF("winCreateScreenResources - shadowAdd () failed\n"); - return FALSE; - } - - return result; -} - -/* See Porting Layer Definition - p. 20 */ -Bool -winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - VisualPtr pVisual = NULL; - - int iReturn; - - /* 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); - - winErrorFVerb(2, "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; - } - - if ((pScreenInfo->dwBPP == 8) && (pScreenInfo->fCompositeWM)) { - ErrorF("-compositewm disabled due to 8bpp depth\n"); - pScreenInfo->fCompositeWM = FALSE; - } - - /* 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))) { - 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 desirable, - * as it keeps the Magic window viewable when switching to - * other X clients that use the default colormap. - */ - pScreen->blackPixel = 0; - pScreen->whitePixel = 1; - } - - /* 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; - - /* Render extension initialization, calls miPictureInit */ - if (!fbPictureInit(pScreen, NULL, 0)) { - ErrorF("winFinishScreenInitFB - fbPictureInit () failed\n"); - return FALSE; - } - -#ifdef RANDR - /* Initialize resize and rotate support */ - if (!winRandRInit(pScreen)) { - ErrorF("winFinishScreenInitFB - winRandRInit () failed\n"); - return FALSE; - } -#endif - - /* Setup the cursor routines */ -#if CYGDEBUG - winDebug("winFinishScreenInitFB - Calling miDCInitialize ()\n"); -#endif - miDCInitialize(pScreen, &g_winPointerCursorFuncs); - - /* KDrive does winCreateDefColormap right after miDCInitialize */ - /* Create a default colormap */ -#if CYGDEBUG - winDebug("winFinishScreenInitFB - Calling winCreateDefColormap ()\n"); -#endif - 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_DDNL)) { -#if CYGDEBUG - winDebug("winFinishScreenInitFB - Calling shadowSetup ()\n"); -#endif - 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; - } - - /* Handle rootless mode */ - if (pScreenInfo->fRootless) { - /* Define the WRAP macro temporarily for local use */ -#define WRAP(a) \ - if (pScreen->a) { \ - pScreenPriv->a = pScreen->a; \ - } else { \ - winDebug("winScreenInit - null screen fn " #a "\n"); \ - pScreenPriv->a = NULL; \ - } - - /* Save a pointer to each lower-level window procedure */ - WRAP(CreateWindow); - WRAP(DestroyWindow); - WRAP(RealizeWindow); - WRAP(UnrealizeWindow); - WRAP(PositionWindow); - WRAP(ChangeWindowAttributes); - WRAP(SetShape); - - /* Assign rootless window procedures to be top level procedures */ - pScreen->CreateWindow = winCreateWindowRootless; - pScreen->DestroyWindow = winDestroyWindowRootless; - pScreen->PositionWindow = winPositionWindowRootless; - /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless; */ - pScreen->RealizeWindow = winMapWindowRootless; - pScreen->UnrealizeWindow = winUnmapWindowRootless; - pScreen->SetShape = winSetShapeRootless; - - /* Undefine the WRAP macro, as it is not needed elsewhere */ -#undef WRAP - } - - /* Handle multi window mode */ - else if (pScreenInfo->fMultiWindow) { - /* Define the WRAP macro temporarily for local use */ -#define WRAP(a) \ - if (pScreen->a) { \ - pScreenPriv->a = pScreen->a; \ - } else { \ - winDebug("null screen fn " #a "\n"); \ - pScreenPriv->a = NULL; \ - } - - /* Save a pointer to each lower-level window procedure */ - WRAP(CreateWindow); - WRAP(DestroyWindow); - WRAP(RealizeWindow); - WRAP(UnrealizeWindow); - WRAP(PositionWindow); - WRAP(ChangeWindowAttributes); - WRAP(ReparentWindow); - WRAP(RestackWindow); - WRAP(ResizeWindow); - WRAP(MoveWindow); - WRAP(CopyWindow); - WRAP(SetShape); - WRAP(ModifyPixmapHeader); - - /* 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; - - if (pScreenInfo->fCompositeWM) { - pScreen->CreatePixmap = winCreatePixmapMultiwindow; - pScreen->DestroyPixmap = winDestroyPixmapMultiwindow; - pScreen->ModifyPixmapHeader = winModifyPixmapHeaderMultiwindow; - } - - /* Undefine the WRAP macro, as it is not needed elsewhere */ -#undef WRAP - } - - /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */ - pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; - - /* 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; - - - if (pScreenInfo->fMultiWindow) { -#if CYGDEBUG || YES - winDebug("winFinishScreenInitFB - Calling winInitWM.\n"); -#endif - - /* Initialize multi window mode */ - if (!winInitWM(&pScreenPriv->pWMInfo, - &pScreenPriv->ptWMProc, - &pScreenPriv->ptXMsgProc, - &pScreenPriv->pmServerStarted, - pScreenInfo->dwScreen, - (HWND) &pScreenPriv->hwndScreen, - pScreenInfo->fCompositeWM)) { - ErrorF("winFinishScreenInitFB - winInitWM () failed.\n"); - return FALSE; - } - } - - /* Tell the server that we are enabled */ - pScreenPriv->fEnabled = TRUE; - - /* Tell the server that we have a valid depth */ - pScreenPriv->fBadDepth = FALSE; - -#if CYGDEBUG || YES - winDebug("winFinishScreenInitFB - returning\n"); -#endif - - return TRUE; -} diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c deleted file mode 100644 index 290176920..000000000 --- a/hw/xwin/winshadddnl.c +++ /dev/null @@ -1,1217 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -#define FAIL_MSG_MAX_BLT 10 - -/* - * Local prototypes - */ - -static Bool - winAllocateFBShadowDDNL(ScreenPtr pScreen); - -static void - winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf); - -static Bool - winCloseScreenShadowDDNL(ScreenPtr pScreen); - -static Bool - winInitVisualsShadowDDNL(ScreenPtr pScreen); - -static Bool - winAdjustVideoModeShadowDDNL(ScreenPtr pScreen); - -static Bool - winBltExposedRegionsShadowDDNL(ScreenPtr pScreen); - -static Bool - winActivateAppShadowDDNL(ScreenPtr pScreen); - -static Bool - winRedrawScreenShadowDDNL(ScreenPtr pScreen); - -static Bool - winRealizeInstalledPaletteShadowDDNL(ScreenPtr pScreen); - -static Bool - winInstallColormapShadowDDNL(ColormapPtr pColormap); - -static Bool - winStoreColorsShadowDDNL(ColormapPtr pmap, int ndef, xColorItem * pdefs); - -static Bool - winCreateColormapShadowDDNL(ColormapPtr pColormap); - -static Bool - winDestroyColormapShadowDDNL(ColormapPtr pColormap); - -static Bool - winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen); - -static Bool - winReleasePrimarySurfaceShadowDDNL(ScreenPtr pScreen); - -/* - * Create the primary surface and attach the clipper. - * Used for both the initial surface creation and during - * WM_DISPLAYCHANGE messages. - */ - -static Bool -winCreatePrimarySurfaceShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - HRESULT ddrval = DD_OK; - DDSURFACEDESC2 ddsd; - - winDebug("winCreatePrimarySurfaceShadowDDNL - Creating primary surface\n"); - - /* Describe the primary surface */ - ZeroMemory(&ddsd, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - /* Create the primary surface */ - ddrval = IDirectDraw4_CreateSurface(pScreenPriv->pdd4, - &ddsd, - &pScreenPriv->pddsPrimary4, NULL); - pScreenPriv->fRetryCreateSurface = FALSE; - if (FAILED(ddrval)) { - if (ddrval == DDERR_NOEXCLUSIVEMODE) { - /* Recreating the surface failed. Mark screen to retry later */ - pScreenPriv->fRetryCreateSurface = TRUE; - winDebug("winCreatePrimarySurfaceShadowDDNL - Could not create " - "primary surface: DDERR_NOEXCLUSIVEMODE\n"); - } - else { - ErrorF("winCreatePrimarySurfaceShadowDDNL - Could not create " - "primary surface: %08x\n", (unsigned int) ddrval); - } - return FALSE; - } - -#if 1 - winDebug("winCreatePrimarySurfaceShadowDDNL - Created primary surface\n"); -#endif - - /* 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; - } - -#if 1 - winDebug("winCreatePrimarySurfaceShadowDDNL - Attached clipper to primary " - "surface\n"); -#endif - - /* Everything was correct */ - return TRUE; -} - -/* - * Detach the clipper and release the primary surface. - * Called from WM_DISPLAYCHANGE. - */ - -static Bool -winReleasePrimarySurfaceShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - winDebug("winReleasePrimarySurfaceShadowDDNL - Hello\n"); - - /* 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; - } - - winDebug("winReleasePrimarySurfaceShadowDDNL - Released primary surface\n"); - - return TRUE; -} - -/* - * Create a DirectDraw surface for the shadow framebuffer; also create - * a primary surface object so we can blit to the display. - * - * Install a DirectDraw clipper on our primary surface object - * that clips our blits to the unobscured client area of our display window. - */ - -Bool -winAllocateFBShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - DDSURFACEDESC2 ddsdShadow; - char *lpSurface = NULL; - DDPIXELFORMAT ddpfPrimary; - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - w %u h %u d %u\n", - (unsigned int)pScreenInfo->dwWidth, - (unsigned int)pScreenInfo->dwHeight, - (unsigned int)pScreenInfo->dwDepth); -#endif - - /* Set the padded screen width */ - pScreenInfo->dwPaddedWidth = PixmapBytePad(pScreenInfo->dwWidth, - pScreenInfo->dwBPP); - - /* Allocate memory for our shadow surface */ - lpSurface = malloc(pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight); - if (lpSurface == NULL) { - ErrorF("winAllocateFBShadowDDNL - Could not allocate bits\n"); - return FALSE; - } - - /* - * Initialize the framebuffer memory so we don't get a - * strange display at startup - */ - ZeroMemory(lpSurface, pScreenInfo->dwPaddedWidth * pScreenInfo->dwHeight); - - /* Create a clipper */ - ddrval = (*g_fpDirectDrawCreateClipper) (0, - &pScreenPriv->pddcPrimary, NULL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not attach clipper: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - Created a clipper\n"); -#endif - - /* 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; - } - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - Attached clipper to window\n"); -#endif - - /* 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; - } - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - Created and initialized DD\n"); -#endif - - /* Get a DirectDraw4 interface pointer */ - ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd, - &IID_IDirectDraw4, - (LPVOID *) &pScreenPriv->pdd4); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Failed DD4 query: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - /* Are we full screen? */ - if (pScreenInfo->fFullScreen) { - DDSURFACEDESC2 ddsdCurrent; - DWORD dwRefreshRateCurrent = 0; - HDC hdc = NULL; - - /* Set the cooperative level to full screen */ - ddrval = IDirectDraw4_SetCooperativeLevel(pScreenPriv->pdd4, - pScreenPriv->hwndScreen, - DDSCL_EXCLUSIVE - | DDSCL_FULLSCREEN); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not set " - "cooperative level: %08x\n", (unsigned int) ddrval); - return FALSE; - } - - /* - * We only need to get the current refresh rate for comparison - * if a refresh rate has been passed on the command line. - */ - if (pScreenInfo->dwRefreshRate != 0) { - ZeroMemory(&ddsdCurrent, sizeof(ddsdCurrent)); - ddsdCurrent.dwSize = sizeof(ddsdCurrent); - - /* Get information about current display settings */ - ddrval = IDirectDraw4_GetDisplayMode(pScreenPriv->pdd4, - &ddsdCurrent); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not get current " - "refresh rate: %08x. Continuing.\n", - (unsigned int) ddrval); - dwRefreshRateCurrent = 0; - } - else { - /* Grab the current refresh rate */ - dwRefreshRateCurrent = ddsdCurrent.u2.dwRefreshRate; - } - } - - /* Clean up the refresh rate */ - if (dwRefreshRateCurrent == pScreenInfo->dwRefreshRate) { - /* - * Refresh rate is non-specified or equal to current. - */ - pScreenInfo->dwRefreshRate = 0; - } - - /* Grab a device context for the screen */ - hdc = GetDC(NULL); - if (hdc == NULL) { - ErrorF("winAllocateFBShadowDDNL - GetDC () failed\n"); - return FALSE; - } - - /* Only change the video mode when different than current mode */ - if (!pScreenInfo->fMultipleMonitors - && (pScreenInfo->dwWidth != GetSystemMetrics(SM_CXSCREEN) - || pScreenInfo->dwHeight != GetSystemMetrics(SM_CYSCREEN) - || pScreenInfo->dwBPP != GetDeviceCaps(hdc, BITSPIXEL) - || pScreenInfo->dwRefreshRate != 0)) { - winDebug("winAllocateFBShadowDDNL - Changing video mode\n"); - - /* Change the video mode to the mode requested, and use the driver default refresh rate on failure */ - ddrval = IDirectDraw4_SetDisplayMode(pScreenPriv->pdd4, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, - pScreenInfo->dwRefreshRate, 0); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not set " - "full screen display mode: %08x\n", - (unsigned int) ddrval); - ErrorF - ("winAllocateFBShadowDDNL - Using default driver refresh rate\n"); - ddrval = - IDirectDraw4_SetDisplayMode(pScreenPriv->pdd4, - pScreenInfo->dwWidth, - pScreenInfo->dwHeight, - pScreenInfo->dwBPP, 0, 0); - if (FAILED(ddrval)) { - ErrorF - ("winAllocateFBShadowDDNL - Could not set default refresh rate " - "full screen display mode: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - } - } - else { - winDebug("winAllocateFBShadowDDNL - Not changing video mode\n"); - } - - /* Release our DC */ - ReleaseDC(NULL, hdc); - hdc = NULL; - } - else { - /* Set the cooperative level for windowed mode */ - ddrval = IDirectDraw4_SetCooperativeLevel(pScreenPriv->pdd4, - pScreenPriv->hwndScreen, - DDSCL_NORMAL); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not set " - "cooperative level: %08x\n", (unsigned int) ddrval); - return FALSE; - } - } - - /* Create the primary surface */ - if (!winCreatePrimarySurfaceShadowDDNL(pScreen)) { - ErrorF("winAllocateFBShadowDDNL - winCreatePrimarySurfaceShadowDDNL " - "failed\n"); - return FALSE; - } - - /* Get primary surface's pixel format */ - ZeroMemory(&ddpfPrimary, sizeof(ddpfPrimary)); - ddpfPrimary.dwSize = sizeof(ddpfPrimary); - ddrval = IDirectDrawSurface4_GetPixelFormat(pScreenPriv->pddsPrimary4, - &ddpfPrimary); - if (FAILED(ddrval)) { - ErrorF("winAllocateFBShadowDDNL - Could not get primary " - "pixformat: %08x\n", (unsigned int) ddrval); - return FALSE; - } - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - Primary masks: %08x %08x %08x " - "dwRGBBitCount: %u\n", - (unsigned int)ddpfPrimary.u2.dwRBitMask, - (unsigned int)ddpfPrimary.u3.dwGBitMask, - (unsigned int)ddpfPrimary.u4.dwBBitMask, - (unsigned int)ddpfPrimary.u1.dwRGBBitCount); -#endif - - /* Describe the shadow surface to be created */ - /* - * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface, - * as drawing, locking, and unlocking take forever - * with video memory surfaces. In addition, - * video memory is a somewhat scarce resource, - * so you shouldn't be allocating video memory when - * you 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; - } - -#if CYGDEBUG || YES - winDebug("winAllocateFBShadowDDNL - Created shadow pitch: %d\n", - (int) ddsdShadow.u1.lPitch); -#endif - - /* Grab the pitch from the surface desc */ - pScreenInfo->dwStride = (ddsdShadow.u1.lPitch * 8) - / pScreenInfo->dwBPP; - -#if CYGDEBUG || YES - winDebug("winAllocateFBShadowDDNL - Created shadow stride: %d\n", - (int) pScreenInfo->dwStride); -#endif - - /* 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; - -#if CYGDEBUG - winDebug("winAllocateFBShadowDDNL - Returning\n"); -#endif - - return TRUE; -} - -static void -winFreeFBShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Free the shadow surface, if there is one */ - if (pScreenPriv->pddsShadow4) { - IDirectDrawSurface4_Release(pScreenPriv->pddsShadow4); - free(pScreenInfo->pfb); - pScreenInfo->pfb = NULL; - pScreenPriv->pddsShadow4 = NULL; - } - - /* Detach the clipper from the primary surface and release the primary surface, if there is one */ - winReleasePrimarySurfaceShadowDDNL(pScreen); - - /* Release the clipper object */ - if (pScreenPriv->pddcPrimary) { - IDirectDrawClipper_Release(pScreenPriv->pddcPrimary); - pScreenPriv->pddcPrimary = NULL; - } - - /* Free the DirectDraw4 object, if there is one */ - if (pScreenPriv->pdd4) { - IDirectDraw4_RestoreDisplayMode(pScreenPriv->pdd4); - IDirectDraw4_Release(pScreenPriv->pdd4); - pScreenPriv->pdd4 = NULL; - } - - /* Free the DirectDraw object, if there is one */ - if (pScreenPriv->pdd) { - IDirectDraw_Release(pScreenPriv->pdd); - pScreenPriv->pdd = NULL; - } - - /* Invalidate the ScreenInfo's fb pointer */ - pScreenInfo->pfb = NULL; -} - -/* - * Transfer the damaged regions of the shadow framebuffer to the display. - */ - -static void -winShadowUpdateDDNL(ScreenPtr pScreen, shadowBufPtr pBuf) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RegionPtr damage = DamageRegion(pBuf->pDamage); - HRESULT ddrval = DD_OK; - RECT rcDest, rcSrc; - POINT ptOrigin; - DWORD dwBox = RegionNumRects(damage); - BoxPtr pBox = RegionRects(damage); - HRGN 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 */ - ddrval = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, - &rcDest, - pScreenPriv->pddsShadow4, - &rcSrc, DDBLT_WAIT, NULL); - if (FAILED(ddrval)) { - static int s_iFailCount = 0; - - if (s_iFailCount < FAIL_MSG_MAX_BLT) { - ErrorF("winShadowUpdateDDNL - IDirectDrawSurface4_Blt () " - "failed: %08x\n", (unsigned int) ddrval); - - ++s_iFailCount; - - if (s_iFailCount == FAIL_MSG_MAX_BLT) { - ErrorF("winShadowUpdateDDNL - IDirectDrawSurface4_Blt " - "failure message maximum (%d) reached. No " - "more failure messages will be printed.\n", - FAIL_MSG_MAX_BLT); - } - } - } - - /* Get a pointer to the next box */ - ++pBox; - } - } - else { - BoxPtr pBoxExtents = RegionExtents(damage); - - /* Compute a GDI region from the damaged region */ - hrgnCombined = - CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2, - pBoxExtents->y2); - - /* Install the GDI region as a clipping region */ - SelectClipRgn(pScreenPriv->hdcScreen, hrgnCombined); - DeleteObject(hrgnCombined); - hrgnCombined = NULL; - -#if CYGDEBUG - winDebug("winShadowUpdateDDNL - be x1 %d y1 %d x2 %d y2 %d\n", - pBoxExtents->x1, pBoxExtents->y1, - pBoxExtents->x2, pBoxExtents->y2); -#endif - - /* 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 = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, - &rcDest, - pScreenPriv->pddsShadow4, - &rcSrc, DDBLT_WAIT, NULL); - - /* Reset the clip region */ - SelectClipRgn(pScreenPriv->hdcScreen, NULL); - } -} - -static Bool -winInitScreenShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* Get a device context for the screen */ - pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen); - - return winAllocateFBShadowDDNL(pScreen); -} - -/* - * Call the wrapped CloseScreen function. - * - * Free our resources and private structures. - */ - -static Bool -winCloseScreenShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - Bool fReturn = TRUE; - -#if CYGDEBUG - winDebug("winCloseScreenShadowDDNL - Freeing screen resources\n"); -#endif - - /* 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) (pScreen); - - winFreeFBShadowDDNL(pScreen); - - /* Free the screen DC */ - ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen); - - /* Delete the window property */ - RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP); - - /* Delete tray icon, if we have one */ - if (!pScreenInfo->fNoTrayIcon) - winDeleteNotifyIcon(pScreenPriv); - - /* Free the exit confirmation dialog box, if it exists */ - if (g_hDlgExit != NULL) { - DestroyWindow(g_hDlgExit); - g_hDlgExit = NULL; - } - - /* Kill our window */ - if (pScreenPriv->hwndScreen) { - DestroyWindow(pScreenPriv->hwndScreen); - pScreenPriv->hwndScreen = NULL; - } - - /* Destroy the thread startup mutex */ - pthread_mutex_destroy(&pScreenPriv->pmServerStarted); - - /* Kill our screeninfo's pointer to the screen */ - pScreenInfo->pScreen = NULL; - - /* Free the screen privates for this screen */ - free((void *) pScreenPriv); - - return fReturn; -} - -/* - * Tell mi what sort of visuals we need. - * - * Generally we only need one visual, as our screen can only - * handle one format at a time, I believe. You may want - * to verify that last sentence. - */ - -static Bool -winInitVisualsShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - DWORD dwRedBits, dwGreenBits, dwBlueBits; - - /* Count the number of ones in each color mask */ - dwRedBits = winCountBits(pScreenPriv->dwRedMask); - dwGreenBits = winCountBits(pScreenPriv->dwGreenMask); - dwBlueBits = winCountBits(pScreenPriv->dwBlueMask); - - /* Store the maximum number of ones in a color mask as the bitsPerRGB */ - if (dwRedBits == 0 || dwGreenBits == 0 || dwBlueBits == 0) - pScreenPriv->dwBitsPerRGB = 8; - else if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwRedBits; - else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwGreenBits; - else - pScreenPriv->dwBitsPerRGB = dwBlueBits; - - winDebug("winInitVisualsShadowDDNL - Masks %08x %08x %08x BPRGB %d d %d " - "bpp %d\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask, - (int) pScreenPriv->dwBitsPerRGB, - (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP); - - /* Create a single visual according to the Windows screen depth */ - switch (pScreenInfo->dwDepth) { - case 24: - case 16: - case 15: - /* Setup the real visual */ - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - -1, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks " - "failed for TrueColor\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) { - ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif - break; - - case 8: - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - pScreenInfo->fFullScreen - ? PseudoColorMask : StaticColorMask, - pScreenPriv->dwBitsPerRGB, - pScreenInfo->fFullScreen - ? PseudoColor : StaticColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowDDNL - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } - break; - - default: - ErrorF("winInitVisualsShadowDDNL - Unknown screen depth\n"); - return FALSE; - } - -#if CYGDEBUG - winDebug("winInitVisualsShadowDDNL - Returning\n"); -#endif - - return TRUE; -} - -/* - * Adjust the user proposed video mode - */ - -static Bool -winAdjustVideoModeShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HDC hdc = NULL; - DWORD dwBPP; - - /* We're in serious trouble if we can't get a DC */ - hdc = GetDC(NULL); - if (hdc == NULL) { - ErrorF("winAdjustVideoModeShadowDDNL - GetDC () failed\n"); - return FALSE; - } - - /* Query GDI for current display depth */ - dwBPP = GetDeviceCaps(hdc, BITSPIXEL); - - /* DirectDraw can only change the depth in fullscreen mode */ - if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) { - /* Otherwise, We'll use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - } - - /* Release our DC */ - ReleaseDC(NULL, hdc); - - return TRUE; -} - -/* - * Blt exposed regions to the screen - */ - -static Bool -winBltExposedRegionsShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RECT rcSrc, rcDest; - POINT ptOrigin; - HDC hdcUpdate; - PAINTSTRUCT ps; - HRESULT ddrval = DD_OK; - Bool fReturn = TRUE; - int i; - - /* Quite common case. The primary surface was lost (maybe because of depth - * change). Try to create a new primary surface. Bail out if this fails */ - if (pScreenPriv->pddsPrimary4 == NULL && pScreenPriv->fRetryCreateSurface && - !winCreatePrimarySurfaceShadowDDNL(pScreen)) { - Sleep(100); - return FALSE; - } - if (pScreenPriv->pddsPrimary4 == NULL) - return FALSE; - - /* BeginPaint gives us an hdc that clips to the invalidated region */ - hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps); - if (hdcUpdate == NULL) { - fReturn = FALSE; - ErrorF("winBltExposedRegionsShadowDDNL - BeginPaint () returned " - "a NULL device context handle. Aborting blit attempt.\n"); - goto winBltExposedRegionsShadowDDNL_Exit; - } - - /* Get the origin of the window in the screen coords */ - ptOrigin.x = pScreenInfo->dwXOffset; - ptOrigin.y = pScreenInfo->dwYOffset; - - MapWindowPoints(pScreenPriv->hwndScreen, - HWND_DESKTOP, (LPPOINT) &ptOrigin, 1); - rcDest.left = ptOrigin.x; - rcDest.right = ptOrigin.x + pScreenInfo->dwWidth; - rcDest.top = ptOrigin.y; - rcDest.bottom = ptOrigin.y + pScreenInfo->dwHeight; - - /* Source can be entire shadow surface, as Blt should clip for us */ - rcSrc.left = 0; - rcSrc.top = 0; - rcSrc.right = pScreenInfo->dwWidth; - rcSrc.bottom = pScreenInfo->dwHeight; - - /* 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 = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, - &rcDest, - pScreenPriv->pddsShadow4, - &rcSrc, DDBLT_WAIT, NULL); - if (ddrval == DDERR_SURFACELOST) { - /* Surface was lost */ - winErrorFVerb(1, "winBltExposedRegionsShadowDDNL - " - "IDirectDrawSurface4_Blt reported that the primary " - "surface was lost, trying to restore, retry: %d\n", - i + 1); - - /* Try to restore the surface, once */ - - ddrval = IDirectDrawSurface4_Restore(pScreenPriv->pddsPrimary4); - winDebug("winBltExposedRegionsShadowDDNL - " - "IDirectDrawSurface4_Restore returned: "); - if (ddrval == DD_OK) - winDebug("DD_OK\n"); - else if (ddrval == DDERR_WRONGMODE) - winDebug("DDERR_WRONGMODE\n"); - else if (ddrval == DDERR_INCOMPATIBLEPRIMARY) - winDebug("DDERR_INCOMPATIBLEPRIMARY\n"); - else if (ddrval == DDERR_UNSUPPORTED) - winDebug("DDERR_UNSUPPORTED\n"); - else if (ddrval == DDERR_INVALIDPARAMS) - winDebug("DDERR_INVALIDPARAMS\n"); - else if (ddrval == DDERR_INVALIDOBJECT) - winDebug("DDERR_INVALIDOBJECT\n"); - else - winDebug("unknown error: %08x\n", (unsigned int) ddrval); - - /* Loop around to try the blit one more time */ - continue; - } - else if (FAILED(ddrval)) { - fReturn = FALSE; - winErrorFVerb(1, "winBltExposedRegionsShadowDDNL - " - "IDirectDrawSurface4_Blt failed, but surface not " - "lost: %08x %d\n", - (unsigned int) ddrval, (int) ddrval); - goto winBltExposedRegionsShadowDDNL_Exit; - } - else { - /* Success, stop looping */ - break; - } - } - - winBltExposedRegionsShadowDDNL_Exit: - /* EndPaint frees the DC */ - if (hdcUpdate != NULL) - EndPaint(pScreenPriv->hwndScreen, &ps); - return fReturn; -} - -/* - * Do any engine-specific application-activation processing - */ - -static Bool -winActivateAppShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* - * Do we have a surface? - * Are we active? - * Are we full screen? - */ - if (pScreenPriv != NULL - && pScreenPriv->pddsPrimary4 != NULL && pScreenPriv->fActive) { - /* Primary surface was lost, restore it */ - IDirectDrawSurface4_Restore(pScreenPriv->pddsPrimary4); - } - - return TRUE; -} - -/* - * Reblit the shadow framebuffer to the screen. - */ - -static Bool -winRedrawScreenShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HRESULT ddrval = DD_OK; - RECT rcSrc, rcDest; - POINT ptOrigin; - - /* Return immediately if we didn't get needed surfaces */ - if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4) - return 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; - - /* Redraw the whole window, to take account for the new colors */ - ddrval = IDirectDrawSurface4_Blt(pScreenPriv->pddsPrimary4, - &rcDest, - pScreenPriv->pddsShadow4, - &rcSrc, DDBLT_WAIT, NULL); - if (FAILED(ddrval)) { - ErrorF("winRedrawScreenShadowDDNL - IDirectDrawSurface4_Blt () " - "failed: %08x\n", (unsigned int) ddrval); - } - - return TRUE; -} - -/* - * Realize the currently installed colormap - */ - -static Bool -winRealizeInstalledPaletteShadowDDNL(ScreenPtr pScreen) -{ - return TRUE; -} - -/* - * Install the specified colormap - */ - -static Bool -winInstallColormapShadowDDNL(ColormapPtr pColormap) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* Install the DirectDraw palette on the primary surface */ - ddrval = IDirectDrawSurface4_SetPalette(pScreenPriv->pddsPrimary4, - pCmapPriv->lpDDPalette); - if (FAILED(ddrval)) { - ErrorF("winInstallColormapShadowDDNL - Failed installing the " - "DirectDraw palette.\n"); - return FALSE; - } - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; - - return TRUE; -} - -/* - * Store the specified colors in the specified colormap - */ - -static Bool -winStoreColorsShadowDDNL(ColormapPtr pColormap, int ndef, xColorItem * pdefs) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - ColormapPtr curpmap = pScreenPriv->pcmapInstalled; - HRESULT ddrval = DD_OK; - - /* Put the X colormap entries into the Windows logical palette */ - ddrval = IDirectDrawPalette_SetEntries(pCmapPriv->lpDDPalette, - 0, - pdefs[0].pixel, - ndef, - pCmapPriv->peColors - + pdefs[0].pixel); - if (FAILED(ddrval)) { - ErrorF("winStoreColorsShadowDDNL - SetEntries () failed: %08x\n", - (unsigned int) ddrval); - return FALSE; - } - - /* Don't install the DirectDraw palette if the colormap is not installed */ - if (pColormap != curpmap) { - return TRUE; - } - - if (!winInstallColormapShadowDDNL(pColormap)) { - ErrorF("winStoreColorsShadowDDNL - Failed installing colormap\n"); - return FALSE; - } - - return TRUE; -} - -/* - * Colormap initialization procedure - */ - -static Bool -winCreateColormapShadowDDNL(ColormapPtr pColormap) -{ - HRESULT ddrval = DD_OK; - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - - /* Create a DirectDraw palette */ - ddrval = IDirectDraw4_CreatePalette(pScreenPriv->pdd4, - DDPCAPS_8BIT | DDPCAPS_ALLOW256, - pCmapPriv->peColors, - &pCmapPriv->lpDDPalette, NULL); - if (FAILED(ddrval)) { - ErrorF("winCreateColormapShadowDDNL - CreatePalette failed\n"); - return FALSE; - } - - return TRUE; -} - -/* - * Colormap destruction procedure - */ - -static Bool -winDestroyColormapShadowDDNL(ColormapPtr pColormap) -{ - winScreenPriv(pColormap->pScreen); - winCmapPriv(pColormap); - HRESULT ddrval = DD_OK; - - /* - * Is colormap to be destroyed the default? - * - * Non-default colormaps should have had winUninstallColormap - * called on them before we get here. The default colormap - * will not have had winUninstallColormap called on it. Thus, - * we need to handle the default colormap in a special way. - */ - if (pColormap->flags & IsDefault) { -#if CYGDEBUG - winDebug - ("winDestroyColormapShadowDDNL - Destroying default colormap\n"); -#endif - - /* - * FIXME: Walk the list of all screens, popping the default - * palette out of each screen device context. - */ - - /* Pop the palette out of the primary surface */ - ddrval = IDirectDrawSurface4_SetPalette(pScreenPriv->pddsPrimary4, - NULL); - if (FAILED(ddrval)) { - ErrorF("winDestroyColormapShadowDDNL - Failed freeing the " - "default colormap DirectDraw palette.\n"); - return FALSE; - } - - /* Clear our private installed colormap pointer */ - pScreenPriv->pcmapInstalled = NULL; - } - - /* Release the palette */ - IDirectDrawPalette_Release(pCmapPriv->lpDDPalette); - - /* Invalidate the colormap privates */ - pCmapPriv->lpDDPalette = NULL; - - return TRUE; -} - -/* - * Set pointers to our engine specific functions - */ - -Bool -winSetEngineFunctionsShadowDDNL(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Set our pointers */ - pScreenPriv->pwinAllocateFB = winAllocateFBShadowDDNL; - pScreenPriv->pwinFreeFB = winFreeFBShadowDDNL; - pScreenPriv->pwinShadowUpdate = winShadowUpdateDDNL; - pScreenPriv->pwinInitScreen = winInitScreenShadowDDNL; - pScreenPriv->pwinCloseScreen = winCloseScreenShadowDDNL; - pScreenPriv->pwinInitVisuals = winInitVisualsShadowDDNL; - pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowDDNL; - if (pScreenInfo->fFullScreen) - pScreenPriv->pwinCreateBoundingWindow = - winCreateBoundingWindowFullScreen; - else - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed; - pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB; - pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowDDNL; - pScreenPriv->pwinBltExposedWindowRegion = NULL; - pScreenPriv->pwinActivateApp = winActivateAppShadowDDNL; - pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowDDNL; - pScreenPriv->pwinRealizeInstalledPalette - = winRealizeInstalledPaletteShadowDDNL; - pScreenPriv->pwinInstallColormap = winInstallColormapShadowDDNL; - pScreenPriv->pwinStoreColors = winStoreColorsShadowDDNL; - pScreenPriv->pwinCreateColormap = winCreateColormapShadowDDNL; - pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowDDNL; - pScreenPriv->pwinCreatePrimarySurface = winCreatePrimarySurfaceShadowDDNL; - pScreenPriv->pwinReleasePrimarySurface = winReleasePrimarySurfaceShadowDDNL; - - return TRUE; -} diff --git a/hw/xwin/winshadgdi.c b/hw/xwin/winshadgdi.c deleted file mode 100644 index 25e16bf76..000000000 --- a/hw/xwin/winshadgdi.c +++ /dev/null @@ -1,1285 +0,0 @@ -/* - *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL HAROLD L HUNT II BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of Harold L Hunt II - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from Harold L Hunt II. - * - * Authors: Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -/* - * Local function prototypes - */ - -static wBOOL CALLBACK winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam); - -static wBOOL CALLBACK winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam); - -static Bool - winAllocateFBShadowGDI(ScreenPtr pScreen); - -static void - winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf); - -static Bool - winCloseScreenShadowGDI(ScreenPtr pScreen); - -static Bool - winInitVisualsShadowGDI(ScreenPtr pScreen); - -static Bool - winAdjustVideoModeShadowGDI(ScreenPtr pScreen); - -static Bool - winBltExposedRegionsShadowGDI(ScreenPtr pScreen); - -static Bool - winBltExposedWindowRegionShadowGDI(ScreenPtr pScreen, WindowPtr pWin); - -static Bool - winActivateAppShadowGDI(ScreenPtr pScreen); - -static Bool - winRedrawScreenShadowGDI(ScreenPtr pScreen); - -static Bool - winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen); - -static Bool - winInstallColormapShadowGDI(ColormapPtr pColormap); - -static Bool - winStoreColorsShadowGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs); - -static Bool - winCreateColormapShadowGDI(ColormapPtr pColormap); - -static Bool - winDestroyColormapShadowGDI(ColormapPtr pColormap); - -/* - * Internal function to get the DIB format that is compatible with the screen - */ - -static - Bool -winQueryScreenDIBFormat(ScreenPtr pScreen, BITMAPINFOHEADER * pbmih) -{ - winScreenPriv(pScreen); - HBITMAP hbmp; - -#if CYGDEBUG - LPDWORD pdw = NULL; -#endif - - /* Create a memory bitmap compatible with the screen */ - hbmp = CreateCompatibleBitmap(pScreenPriv->hdcScreen, 1, 1); - if (hbmp == NULL) { - ErrorF("winQueryScreenDIBFormat - CreateCompatibleBitmap failed\n"); - return FALSE; - } - - /* Initialize our bitmap info header */ - ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - pbmih->biSize = sizeof(BITMAPINFOHEADER); - - /* Get the biBitCount */ - if (!GetDIBits(pScreenPriv->hdcScreen, - hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) { - ErrorF("winQueryScreenDIBFormat - First call to GetDIBits failed\n"); - DeleteObject(hbmp); - return FALSE; - } - -#if CYGDEBUG - /* Get a pointer to bitfields */ - pdw = (DWORD *) ((CARD8 *) pbmih + sizeof(BITMAPINFOHEADER)); - - winDebug("winQueryScreenDIBFormat - 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(pScreenPriv->hdcScreen, - hbmp, 0, 1, NULL, (BITMAPINFO *) pbmih, DIB_RGB_COLORS)) { - ErrorF("winQueryScreenDIBFormat - Second call to GetDIBits " - "failed\n"); - DeleteObject(hbmp); - return FALSE; - } - - /* Free memory */ - DeleteObject(hbmp); - - return TRUE; -} - -/* - * Internal function to determine the GDI bits per rgb and bit masks - */ - -static - Bool -winQueryRGBBitsAndMasks(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - BITMAPINFOHEADER *pbmih = NULL; - Bool fReturn = TRUE; - LPDWORD pdw = NULL; - DWORD dwRedBits, dwGreenBits, dwBlueBits; - - /* Color masks for 8 bpp are standardized */ - if (GetDeviceCaps(pScreenPriv->hdcScreen, RASTERCAPS) & RC_PALETTE) { - /* - * RGB BPP for 8 bit palletes is always 8 - * and the color masks are always 0. - */ - pScreenPriv->dwBitsPerRGB = 8; - pScreenPriv->dwRedMask = 0x0L; - pScreenPriv->dwGreenMask = 0x0L; - pScreenPriv->dwBlueMask = 0x0L; - return TRUE; - } - - /* Color masks for 24 bpp are standardized */ - if (GetDeviceCaps(pScreenPriv->hdcScreen, PLANES) - * GetDeviceCaps(pScreenPriv->hdcScreen, BITSPIXEL) == 24) { - ErrorF("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 = 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)); - -#if CYGDEBUG - winDebug("%s - Masks: %08x %08x %08x\n", __FUNCTION__, - (unsigned int)pdw[0], (unsigned int)pdw[1], (unsigned int)pdw[2]); - winDebug("%s - Bitmap: %dx%d %d bpp %d planes\n", __FUNCTION__, - (int)pbmih->biWidth, (int)pbmih->biHeight, pbmih->biBitCount, - pbmih->biPlanes); - winDebug("%s - Compression: %u %s\n", __FUNCTION__, - (unsigned int)pbmih->biCompression, - (pbmih->biCompression == - BI_RGB ? "(BI_RGB)" : (pbmih->biCompression == - BI_RLE8 ? "(BI_RLE8)" : (pbmih-> - biCompression - == - BI_RLE4 ? - "(BI_RLE4)" - : (pbmih-> - biCompression - == - BI_BITFIELDS - ? - "(BI_BITFIELDS)" - : ""))))); -#endif - - /* Handle BI_RGB case, which is returned by Wine */ - if (pbmih->biCompression == BI_RGB) { - dwRedBits = 5; - dwGreenBits = 5; - dwBlueBits = 5; - - pScreenPriv->dwBitsPerRGB = 5; - - /* Set screen privates masks */ - pScreenPriv->dwRedMask = 0x7c00; - pScreenPriv->dwGreenMask = 0x03e0; - pScreenPriv->dwBlueMask = 0x001f; - } - else { - /* Count the number of bits in each mask */ - dwRedBits = winCountBits(pdw[0]); - dwGreenBits = winCountBits(pdw[1]); - dwBlueBits = winCountBits(pdw[2]); - - /* Find maximum bits per red, green, blue */ - if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwRedBits; - else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits) - pScreenPriv->dwBitsPerRGB = dwGreenBits; - else - pScreenPriv->dwBitsPerRGB = dwBlueBits; - - /* Set screen privates masks */ - pScreenPriv->dwRedMask = pdw[0]; - pScreenPriv->dwGreenMask = pdw[1]; - pScreenPriv->dwBlueMask = pdw[2]; - } - } - else { - ErrorF("winQueryRGBBitsAndMasks - winQueryScreenDIBFormat failed\n"); - fReturn = FALSE; - } - - /* Free memory */ - free(pbmih); - - return fReturn; -} - -/* - * Redraw all ---? - */ - -static wBOOL CALLBACK -winRedrawAllProcShadowGDI(HWND hwnd, LPARAM lParam) -{ - if (hwnd == (HWND) lParam) - return TRUE; - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - return TRUE; -} - -static wBOOL CALLBACK -winRedrawDamagedWindowShadowGDI(HWND hwnd, LPARAM lParam) -{ - BoxPtr pDamage = (BoxPtr) lParam; - RECT rcClient, rcDamage, rcRedraw; - POINT topLeft, bottomRight; - - if (IsIconic(hwnd)) - return TRUE; /* Don't care minimized windows */ - - /* Convert the damaged area from Screen coords to Client coords */ - topLeft.x = pDamage->x1; - topLeft.y = pDamage->y1; - bottomRight.x = pDamage->x2; - bottomRight.y = pDamage->y2; - topLeft.x += GetSystemMetrics(SM_XVIRTUALSCREEN); - bottomRight.x += GetSystemMetrics(SM_XVIRTUALSCREEN); - topLeft.y += GetSystemMetrics(SM_YVIRTUALSCREEN); - bottomRight.y += GetSystemMetrics(SM_YVIRTUALSCREEN); - ScreenToClient(hwnd, &topLeft); - ScreenToClient(hwnd, &bottomRight); - SetRect(&rcDamage, topLeft.x, topLeft.y, bottomRight.x, bottomRight.y); - - GetClientRect(hwnd, &rcClient); - - if (IntersectRect(&rcRedraw, &rcClient, &rcDamage)) { - InvalidateRect(hwnd, &rcRedraw, FALSE); - UpdateWindow(hwnd); - } - return TRUE; -} - -/* - * Allocate a DIB for the shadow framebuffer GDI server - */ - -static Bool -winAllocateFBShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - DIBSECTION dibsection; - Bool fReturn = TRUE; - - /* Describe shadow bitmap to be created */ - pScreenPriv->pbmih->biWidth = pScreenInfo->dwWidth; - pScreenPriv->pbmih->biHeight = -pScreenInfo->dwHeight; - - ErrorF("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(2, "winAllocateFBShadowGDI - CreateDIBSection failed:"); - return FALSE; - } - else { -#if CYGDEBUG - winDebug("winAllocateFBShadowGDI - Shadow buffer allocated\n"); -#endif - } - - /* Get information about the bitmap that was allocated */ - GetObject(pScreenPriv->hbmpShadow, sizeof(dibsection), &dibsection); - -#if CYGDEBUG || YES - /* 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); -#endif - - /* Select the shadow bitmap into the shadow DC */ - SelectObject(pScreenPriv->hdcShadow, pScreenPriv->hbmpShadow); - -#if CYGDEBUG - winDebug("winAllocateFBShadowGDI - Attempting a shadow blit\n"); -#endif - - /* 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) { -#if CYGDEBUG - winDebug("winAllocateFBShadowGDI - Shadow blit success\n"); -#endif - } - else { - winW32Error(2, "winAllocateFBShadowGDI - Shadow blit failure\n"); -#if 0 - return FALSE; -#else - /* ago: ignore this error. The blit fails with wine, but does not - * cause any problems later. */ - - fReturn = TRUE; -#endif - } - - /* 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; - -#if CYGDEBUG || YES - winDebug("winAllocateFBShadowGDI - Created shadow stride: %d\n", - (int) pScreenInfo->dwStride); -#endif - - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); - - return fReturn; -} - -static void -winFreeFBShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Free the shadow bitmap */ - DeleteObject(pScreenPriv->hbmpShadow); - - /* Invalidate the ScreenInfo's fb pointer */ - pScreenInfo->pfb = NULL; -} - -/* - * Blit the damaged regions of the shadow fb to the screen - */ - -static void -winShadowUpdateGDI(ScreenPtr pScreen, shadowBufPtr pBuf) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - RegionPtr damage = DamageRegion(pBuf->pDamage); - DWORD dwBox = RegionNumRects(damage); - BoxPtr pBox = RegionRects(damage); - int x, y, w, h; - HRGN hrgnCombined = NULL; - -#ifdef XWIN_UPDATESTATS - static DWORD s_dwNonUnitRegions = 0; - static DWORD s_dwTotalUpdates = 0; - static DWORD s_dwTotalBoxes = 0; -#endif - BoxPtr pBoxExtents = RegionExtents(damage); - - /* - * Return immediately if the app is not active - * and we are fullscreen, or if we have a bad display depth - */ - if ((!pScreenPriv->fActive && pScreenInfo->fFullScreen) - || pScreenPriv->fBadDepth) - return; - -#ifdef XWIN_UPDATESTATS - ++s_dwTotalUpdates; - s_dwTotalBoxes += dwBox; - - if (dwBox != 1) { - ++s_dwNonUnitRegions; - ErrorF("winShadowUpdatGDI - dwBox: %d\n", dwBox); - } - - if ((s_dwTotalUpdates % 100) == 0) - ErrorF("winShadowUpdateGDI - %d%% non-unity regions, avg boxes: %d " - "nu: %d tu: %d\n", - (s_dwNonUnitRegions * 100) / s_dwTotalUpdates, - s_dwTotalBoxes / s_dwTotalUpdates, - s_dwNonUnitRegions, s_dwTotalUpdates); -#endif /* XWIN_UPDATESTATS */ - - /* - * Handle small regions with multiple blits, - * handle large regions by creating a clipping region and - * doing a single blit constrained to that clipping region. - */ - if (!pScreenInfo->fMultiWindow && - (pScreenInfo->dwClipUpdatesNBoxes == 0 || - dwBox < pScreenInfo->dwClipUpdatesNBoxes)) { - /* Loop through all boxes in the damaged region */ - while (dwBox--) { - /* - * Calculate x offset, y offset, width, and height for - * current damage box - */ - x = pBox->x1; - y = pBox->y1; - w = pBox->x2 - pBox->x1; - h = pBox->y2 - pBox->y1; - - BitBlt(pScreenPriv->hdcScreen, - x, y, w, h, pScreenPriv->hdcShadow, x, y, SRCCOPY); - - /* Get a pointer to the next box */ - ++pBox; - } - } - else if (!pScreenInfo->fMultiWindow) { - - /* Compute a GDI region from the damaged region */ - hrgnCombined = - CreateRectRgn(pBoxExtents->x1, pBoxExtents->y1, pBoxExtents->x2, - pBoxExtents->y2); - - /* 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); - } - - /* Redraw all multiwindow windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, - winRedrawDamagedWindowShadowGDI, - (LPARAM) pBoxExtents); -} - -static Bool -winInitScreenShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - - /* Get device contexts for the screen and shadow bitmap */ - pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen); - pScreenPriv->hdcShadow = CreateCompatibleDC(pScreenPriv->hdcScreen); - - /* Allocate bitmap info header */ - pScreenPriv->pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)); - if (pScreenPriv->pbmih == NULL) { - ErrorF("winInitScreenShadowGDI - malloc () failed\n"); - return FALSE; - } - - /* Query the screen format */ - if (!winQueryScreenDIBFormat(pScreen, pScreenPriv->pbmih)) { - ErrorF("winInitScreenShadowGDI - winQueryScreenDIBFormat failed\n"); - return FALSE; - } - - /* Determine our color masks */ - if (!winQueryRGBBitsAndMasks(pScreen)) { - ErrorF("winInitScreenShadowGDI - winQueryRGBBitsAndMasks failed\n"); - return FALSE; - } - - return winAllocateFBShadowGDI(pScreen); -} - -/* See Porting Layer Definition - p. 33 */ -/* - * We wrap whatever CloseScreen procedure was specified by fb; - * a pointer to said procedure is stored in our privates. - */ - -static Bool -winCloseScreenShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - Bool fReturn = TRUE; - -#if CYGDEBUG - winDebug("winCloseScreenShadowGDI - Freeing screen resources\n"); -#endif - - /* 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) (pScreen); - - /* Delete the window property */ - RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP); - - /* Free the shadow DC; which allows the bitmap to be freed */ - DeleteDC(pScreenPriv->hdcShadow); - - winFreeFBShadowGDI(pScreen); - - /* Free the screen DC */ - ReleaseDC(pScreenPriv->hwndScreen, pScreenPriv->hdcScreen); - - /* Delete tray icon, if we have one */ - if (!pScreenInfo->fNoTrayIcon) - winDeleteNotifyIcon(pScreenPriv); - - /* Free the exit confirmation dialog box, if it exists */ - if (g_hDlgExit != NULL) { - DestroyWindow(g_hDlgExit); - g_hDlgExit = NULL; - } - - /* Kill our window */ - if (pScreenPriv->hwndScreen) { - DestroyWindow(pScreenPriv->hwndScreen); - pScreenPriv->hwndScreen = NULL; - } - - /* Destroy the thread startup mutex */ - pthread_mutex_destroy(&pScreenPriv->pmServerStarted); - - /* Invalidate our screeninfo's pointer to the screen */ - pScreenInfo->pScreen = NULL; - - /* Free the screen privates for this screen */ - free((void *) pScreenPriv); - - return fReturn; -} - -/* - * Tell mi what sort of visuals we need. - * - * Generally we only need one visual, as our screen can only - * handle one format at a time, I believe. You may want - * to verify that last sentence. - */ - -static Bool -winInitVisualsShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Display debugging information */ - ErrorF("winInitVisualsShadowGDI - Masks %08x %08x %08x BPRGB %d d %d " - "bpp %d\n", - (unsigned int) pScreenPriv->dwRedMask, - (unsigned int) pScreenPriv->dwGreenMask, - (unsigned int) pScreenPriv->dwBlueMask, - (int) pScreenPriv->dwBitsPerRGB, - (int) pScreenInfo->dwDepth, (int) pScreenInfo->dwBPP); - - /* Create a single visual according to the Windows screen depth */ - switch (pScreenInfo->dwDepth) { - case 24: - case 16: - case 15: - /* Setup the real visual */ - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - TrueColorMask, - pScreenPriv->dwBitsPerRGB, - -1, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } - -#ifdef XWIN_EMULATEPSEUDO - if (!pScreenInfo->fEmulatePseudo) - break; - - /* Setup a pseudocolor visual */ - if (!miSetVisualTypesAndMasks(8, PseudoColorMask, 8, -1, 0, 0, 0)) { - ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed for PseudoColor\n"); - return FALSE; - } -#endif - break; - - case 8: - if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth, - PseudoColorMask, - pScreenPriv->dwBitsPerRGB, - PseudoColor, - pScreenPriv->dwRedMask, - pScreenPriv->dwGreenMask, - pScreenPriv->dwBlueMask)) { - ErrorF("winInitVisualsShadowGDI - miSetVisualTypesAndMasks " - "failed\n"); - return FALSE; - } - break; - - default: - ErrorF("winInitVisualsShadowGDI - Unknown screen depth\n"); - return FALSE; - } - -#if CYGDEBUG - winDebug("winInitVisualsShadowGDI - Returning\n"); -#endif - - return TRUE; -} - -/* - * Adjust the proposed video mode - */ - -static Bool -winAdjustVideoModeShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - HDC hdc; - DWORD dwBPP; - - hdc = GetDC(NULL); - - /* We're in serious trouble if we can't get a DC */ - if (hdc == NULL) { - ErrorF("winAdjustVideoModeShadowGDI - GetDC () failed\n"); - return FALSE; - } - - /* Query GDI for current display depth */ - dwBPP = GetDeviceCaps(hdc, BITSPIXEL); - - /* GDI cannot change the screen depth, so always use GDI's depth */ - pScreenInfo->dwBPP = dwBPP; - - /* Release our DC */ - ReleaseDC(NULL, hdc); - hdc = NULL; - - return TRUE; -} - -/* - * Blt exposed regions to the screen - */ - -static Bool -winBltExposedRegionsShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - winPrivCmapPtr pCmapPriv = NULL; - HDC hdcUpdate; - PAINTSTRUCT ps; - - /* BeginPaint gives us an hdc that clips to the invalidated region */ - hdcUpdate = BeginPaint(pScreenPriv->hwndScreen, &ps); - /* Avoid the BitBlt if the PAINTSTRUCT region is bogus */ - if (ps.rcPaint.right == 0 && ps.rcPaint.bottom == 0 && - ps.rcPaint.left == 0 && ps.rcPaint.top == 0) { - EndPaint(pScreenPriv->hwndScreen, &ps); - return 0; - } - - /* Realize the palette, if we have one */ - if (pScreenPriv->pcmapInstalled != NULL) { - pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled); - - SelectPalette(hdcUpdate, pCmapPriv->hPalette, FALSE); - RealizePalette(hdcUpdate); - } - - /* Try to copy from the shadow buffer to the invalidated region */ - if (!BitBlt(hdcUpdate, - ps.rcPaint.left, ps.rcPaint.top, - ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - ps.rcPaint.top, - pScreenPriv->hdcShadow, - ps.rcPaint.left, - ps.rcPaint.top, - SRCCOPY)) { - LPVOID lpMsgBuf; - - /* Display an 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("winBltExposedRegionsShadowGDI - BitBlt failed: %s\n", - (LPSTR) lpMsgBuf); - LocalFree(lpMsgBuf); - } - - /* EndPaint frees the DC */ - EndPaint(pScreenPriv->hwndScreen, &ps); - - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, - (LPARAM) pScreenPriv->hwndScreen); - - return TRUE; -} - -/* - * Blt exposed region to the given HWND - */ - -static Bool -winBltExposedWindowRegionShadowGDI(ScreenPtr pScreen, WindowPtr pWin) -{ - winScreenPriv(pScreen); - winPrivWinPtr pWinPriv = winGetWindowPriv(pWin); - - HWND hWnd = pWinPriv->hWnd; - HDC hdcUpdate; - PAINTSTRUCT ps; - - hdcUpdate = BeginPaint(hWnd, &ps); - /* Avoid the BitBlt if the PAINTSTRUCT region 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 COMPOSITE - if (pWin->redirectDraw != RedirectDrawNone) { - HBITMAP hBitmap; - HDC hdcPixmap; - PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin); - winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap); - - /* window pixmap format is the same as the screen pixmap */ - assert(pPixmap->drawable.bitsPerPixel > 8); - - /* Get the window bitmap from the pixmap */ - hBitmap = pPixmapPriv->hBitmap; - - /* XXX: There may be a need for a slow-path here: If hBitmap is NULL - (because we couldn't back the pixmap with a Windows DIB), we should - fall-back to creating a Windows DIB from the pixmap, then deleting it - after the BitBlt (as this this code did before the fast-path was - added). */ - if (!hBitmap) { - ErrorF("winBltExposedWindowRegionShadowGDI - slow path unimplemented\n"); - } - - /* Select the window bitmap into a screen-compatible DC */ - hdcPixmap = CreateCompatibleDC(pScreenPriv->hdcScreen); - SelectObject(hdcPixmap, hBitmap); - - /* Blt from the window bitmap to the invalidated region */ - if (!BitBlt(hdcUpdate, - ps.rcPaint.left, ps.rcPaint.top, - ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - ps.rcPaint.top, - hdcPixmap, - ps.rcPaint.left + pWin->borderWidth, - ps.rcPaint.top + pWin->borderWidth, - SRCCOPY)) - ErrorF("winBltExposedWindowRegionShadowGDI - BitBlt failed: 0x%08x\n", - GetLastError()); - - /* Release DC */ - DeleteDC(hdcPixmap); - } - else -#endif - { - /* Try to copy from the shadow buffer to the invalidated region */ - if (!BitBlt(hdcUpdate, - ps.rcPaint.left, ps.rcPaint.top, - ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - ps.rcPaint.top, - pScreenPriv->hdcShadow, - ps.rcPaint.left + pWin->drawable.x, - ps.rcPaint.top + pWin->drawable.y, - SRCCOPY)) { - LPVOID lpMsgBuf; - - /* Display an 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("winBltExposedWindowRegionShadowGDI - BitBlt failed: %s\n", - (LPSTR) lpMsgBuf); - LocalFree(lpMsgBuf); - } - } - - /* If part of the invalidated region is outside the window (which can happen - if the native window is being re-sized), fill that area with black */ - if (ps.rcPaint.right > ps.rcPaint.left + pWin->drawable.width) { - BitBlt(hdcUpdate, - ps.rcPaint.left + pWin->drawable.width, - ps.rcPaint.top, - ps.rcPaint.right - (ps.rcPaint.left + pWin->drawable.width), - ps.rcPaint.bottom - ps.rcPaint.top, - NULL, - 0, 0, - BLACKNESS); - } - - if (ps.rcPaint.bottom > ps.rcPaint.top + pWin->drawable.height) { - BitBlt(hdcUpdate, - ps.rcPaint.left, - ps.rcPaint.top + pWin->drawable.height, - ps.rcPaint.right - ps.rcPaint.left, - ps.rcPaint.bottom - (ps.rcPaint.top + pWin->drawable.height), - NULL, - 0, 0, - BLACKNESS); - } - - /* EndPaint frees the DC */ - EndPaint(hWnd, &ps); - - return TRUE; -} - -/* - * Do any engine-specific appliation-activation processing - */ - -static Bool -winActivateAppShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* - * 2004/04/12 - Harold - We perform the restoring or minimizing - * manually for ShadowGDI in fullscreen modes so that this engine - * will perform just like ShadowDD and ShadowDDNL in fullscreen mode; - * if we do not do this then our fullscreen window will appear in the - * z-order when it is deactivated and it can be uncovered by resizing - * or minimizing another window that is on top of it, which is not how - * the DirectDraw engines work. Therefore we keep this code here to - * make sure that all engines work the same in fullscreen mode. - */ - - /* - * Are we active? - * Are we fullscreen? - */ - if (pScreenPriv->fActive && pScreenInfo->fFullScreen) { - /* - * Activating, attempt to bring our window - * to the top of the display - */ - ShowWindow(pScreenPriv->hwndScreen, SW_RESTORE); - } - else if (!pScreenPriv->fActive && pScreenInfo->fFullScreen) { - /* - * Deactivating, stuff our window onto the - * task bar. - */ - ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE); - } - - return TRUE; -} - -/* - * Reblit the shadow framebuffer to the screen. - */ - -static Bool -winRedrawScreenShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Redraw the whole window, to take account for the new colors */ - BitBlt(pScreenPriv->hdcScreen, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, 0, 0, SRCCOPY); - - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); - - return TRUE; -} - -/* - * Realize the currently installed colormap - */ - -static Bool -winRealizeInstalledPaletteShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winPrivCmapPtr pCmapPriv = NULL; - -#if CYGDEBUG - winDebug("winRealizeInstalledPaletteShadowGDI\n"); -#endif - - /* Don't do anything if there is not a colormap */ - if (pScreenPriv->pcmapInstalled == NULL) { -#if CYGDEBUG - winDebug("winRealizeInstalledPaletteShadowGDI - No colormap " - "installed\n"); -#endif - return TRUE; - } - - pCmapPriv = winGetCmapPriv(pScreenPriv->pcmapInstalled); - - /* Realize our palette for the screen */ - if (RealizePalette(pScreenPriv->hdcScreen) == GDI_ERROR) { - ErrorF("winRealizeInstalledPaletteShadowGDI - RealizePalette () " - "failed\n"); - return FALSE; - } - - /* Set the DIB color table */ - if (SetDIBColorTable(pScreenPriv->hdcShadow, - 0, - WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) { - ErrorF("winRealizeInstalledPaletteShadowGDI - SetDIBColorTable () " - "failed\n"); - return FALSE; - } - - return TRUE; -} - -/* - * Install the specified colormap - */ - -static Bool -winInstallColormapShadowGDI(ColormapPtr pColormap) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - winCmapPriv(pColormap); - - /* - * Tell Windows to install the new colormap - */ - if (SelectPalette(pScreenPriv->hdcScreen, - pCmapPriv->hPalette, FALSE) == NULL) { - ErrorF("winInstallColormapShadowGDI - SelectPalette () failed\n"); - return FALSE; - } - - /* Realize the palette */ - if (GDI_ERROR == RealizePalette(pScreenPriv->hdcScreen)) { - ErrorF("winInstallColormapShadowGDI - RealizePalette () failed\n"); - return FALSE; - } - - /* Set the DIB color table */ - if (SetDIBColorTable(pScreenPriv->hdcShadow, - 0, - WIN_NUM_PALETTE_ENTRIES, pCmapPriv->rgbColors) == 0) { - ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n"); - return FALSE; - } - - /* Redraw the whole window, to take account for the new colors */ - BitBlt(pScreenPriv->hdcScreen, - 0, 0, - pScreenInfo->dwWidth, pScreenInfo->dwHeight, - pScreenPriv->hdcShadow, 0, 0, SRCCOPY); - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; - - /* Redraw all windows */ - if (pScreenInfo->fMultiWindow) - EnumThreadWindows(g_dwCurrentThreadID, winRedrawAllProcShadowGDI, 0); - - return TRUE; -} - -/* - * Store the specified colors in the specified colormap - */ - -static Bool -winStoreColorsShadowGDI(ColormapPtr pColormap, int ndef, xColorItem * pdefs) -{ - ScreenPtr pScreen = pColormap->pScreen; - - winScreenPriv(pScreen); - winCmapPriv(pColormap); - ColormapPtr curpmap = pScreenPriv->pcmapInstalled; - - /* Put the X colormap entries into the Windows logical palette */ - if (SetPaletteEntries(pCmapPriv->hPalette, - pdefs[0].pixel, - ndef, pCmapPriv->peColors + pdefs[0].pixel) == 0) { - ErrorF("winStoreColorsShadowGDI - SetPaletteEntries () failed\n"); - return FALSE; - } - - /* Don't install the Windows palette if the colormap is not installed */ - if (pColormap != curpmap) { - return TRUE; - } - - /* Try to install the newly modified colormap */ - if (!winInstallColormapShadowGDI(pColormap)) { - ErrorF("winInstallColormapShadowGDI - winInstallColormapShadowGDI " - "failed\n"); - return FALSE; - } - -#if 0 - /* Tell Windows that the palette has changed */ - RealizePalette(pScreenPriv->hdcScreen); - - /* Set the DIB color table */ - if (SetDIBColorTable(pScreenPriv->hdcShadow, - pdefs[0].pixel, - ndef, pCmapPriv->rgbColors + pdefs[0].pixel) == 0) { - ErrorF("winInstallColormapShadowGDI - SetDIBColorTable () failed\n"); - return FALSE; - } - - /* Save a pointer to the newly installed colormap */ - pScreenPriv->pcmapInstalled = pColormap; -#endif - - return TRUE; -} - -/* - * Colormap initialization procedure - */ - -static Bool -winCreateColormapShadowGDI(ColormapPtr pColormap) -{ - LPLOGPALETTE lpPaletteNew = NULL; - DWORD dwEntriesMax; - VisualPtr pVisual; - HPALETTE hpalNew = NULL; - - winCmapPriv(pColormap); - - /* Get a pointer to the visual that the colormap belongs to */ - pVisual = pColormap->pVisual; - - /* Get the maximum number of palette entries for this visual */ - dwEntriesMax = pVisual->ColormapEntries; - - /* Allocate a Windows logical color palette with max entries */ - lpPaletteNew = malloc(sizeof(LOGPALETTE) - + (dwEntriesMax - 1) * sizeof(PALETTEENTRY)); - if (lpPaletteNew == NULL) { - ErrorF("winCreateColormapShadowGDI - Couldn't allocate palette " - "with %d entries\n", (int) dwEntriesMax); - return FALSE; - } - - /* Zero out the colormap */ - ZeroMemory(lpPaletteNew, sizeof(LOGPALETTE) - + (dwEntriesMax - 1) * sizeof(PALETTEENTRY)); - - /* Set the logical palette structure */ - lpPaletteNew->palVersion = 0x0300; - lpPaletteNew->palNumEntries = dwEntriesMax; - - /* Tell Windows to create the palette */ - hpalNew = CreatePalette(lpPaletteNew); - if (hpalNew == NULL) { - ErrorF("winCreateColormapShadowGDI - CreatePalette () failed\n"); - free(lpPaletteNew); - return FALSE; - } - - /* Save the Windows logical palette handle in the X colormaps' privates */ - pCmapPriv->hPalette = hpalNew; - - /* Free the palette initialization memory */ - free(lpPaletteNew); - - return TRUE; -} - -/* - * Colormap destruction procedure - */ - -static Bool -winDestroyColormapShadowGDI(ColormapPtr pColormap) -{ - winScreenPriv(pColormap->pScreen); - winCmapPriv(pColormap); - - /* - * Is colormap to be destroyed the default? - * - * Non-default colormaps should have had winUninstallColormap - * called on them before we get here. The default colormap - * will not have had winUninstallColormap called on it. Thus, - * we need to handle the default colormap in a special way. - */ - if (pColormap->flags & IsDefault) { -#if CYGDEBUG - winDebug("winDestroyColormapShadowGDI - Destroying default " - "colormap\n"); -#endif - - /* - * FIXME: Walk the list of all screens, popping the default - * palette out of each screen device context. - */ - - /* Pop the palette out of the device context */ - SelectPalette(pScreenPriv->hdcScreen, - GetStockObject(DEFAULT_PALETTE), FALSE); - - /* Clear our private installed colormap pointer */ - pScreenPriv->pcmapInstalled = NULL; - } - - /* Try to delete the logical palette */ - if (DeleteObject(pCmapPriv->hPalette) == 0) { - ErrorF("winDestroyColormap - DeleteObject () failed\n"); - return FALSE; - } - - /* Invalidate the colormap privates */ - pCmapPriv->hPalette = NULL; - - return TRUE; -} - -/* - * Set engine specific functions - */ - -Bool -winSetEngineFunctionsShadowGDI(ScreenPtr pScreen) -{ - winScreenPriv(pScreen); - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - /* Set our pointers */ - pScreenPriv->pwinAllocateFB = winAllocateFBShadowGDI; - pScreenPriv->pwinFreeFB = winFreeFBShadowGDI; - pScreenPriv->pwinShadowUpdate = winShadowUpdateGDI; - pScreenPriv->pwinInitScreen = winInitScreenShadowGDI; - pScreenPriv->pwinCloseScreen = winCloseScreenShadowGDI; - pScreenPriv->pwinInitVisuals = winInitVisualsShadowGDI; - pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeShadowGDI; - if (pScreenInfo->fFullScreen) - pScreenPriv->pwinCreateBoundingWindow = - winCreateBoundingWindowFullScreen; - else - pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed; - pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB; - pScreenPriv->pwinBltExposedRegions = winBltExposedRegionsShadowGDI; - pScreenPriv->pwinBltExposedWindowRegion = winBltExposedWindowRegionShadowGDI; - pScreenPriv->pwinActivateApp = winActivateAppShadowGDI; - pScreenPriv->pwinRedrawScreen = winRedrawScreenShadowGDI; - pScreenPriv->pwinRealizeInstalledPalette = - winRealizeInstalledPaletteShadowGDI; - pScreenPriv->pwinInstallColormap = winInstallColormapShadowGDI; - pScreenPriv->pwinStoreColors = winStoreColorsShadowGDI; - pScreenPriv->pwinCreateColormap = winCreateColormapShadowGDI; - pScreenPriv->pwinDestroyColormap = winDestroyColormapShadowGDI; - pScreenPriv->pwinCreatePrimarySurface = NULL; - pScreenPriv->pwinReleasePrimarySurface = NULL; - - return TRUE; -} diff --git a/hw/xwin/wintaskbar.c b/hw/xwin/wintaskbar.c deleted file mode 100644 index 401ec175a..000000000 --- a/hw/xwin/wintaskbar.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice (including the next - paragraph) shall be included in all copies or substantial portions of the - Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - DEALINGS IN THE SOFTWARE. -*/ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" -#include "winwindow.h" - -const GUID CLSID_TaskbarList = {0x56fdf344,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}}; -const GUID IID_ITaskbarList = {0x56fdf342,0xfd6d,0x11d0,{0x95,0x8a,0x0,0x60,0x97,0xc9,0xa0,0x90}}; - -#ifdef INTERFACE -#undef INTERFACE -#endif - -#define INTERFACE ITaskbarList -DECLARE_INTERFACE_(ITaskbarList, IUnknown) -{ - /* IUnknown methods */ - STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE; - STDMETHOD_(ULONG, AddRef) (THIS) PURE; - STDMETHOD_(ULONG, Release) (THIS) PURE; - - /* ITaskbarList methods */ - STDMETHOD(HrInit) (THIS) PURE; - STDMETHOD(AddTab) (THIS_ HWND hWnd) PURE; - STDMETHOD(DeleteTab) (THIS_ HWND hWnd) PURE; - STDMETHOD(ActivateTab) (THIS_ HWND hWnd) PURE; - STDMETHOD(SetActiveAlt) (THIS_ HWND hWnd) PURE; -}; -#undef INTERFACE - -/* - The stuff above needs to be in win32api headers, not defined here, - or at least generated from the MIDL :-) -*/ - -/* - This is unnecessarily heavyweight, we could just call CoInitialize() once at - startup and CoUninitialize() once at shutdown -*/ - -/* - The documentation for ITaskbarList::AddTab says that we are responsible for - deleting the tab ourselves when the window is deleted, but that doesn't actually - seem to be the case -*/ - -void winShowWindowOnTaskbar(HWND hWnd, Bool show) -{ - ITaskbarList* pTaskbarList = NULL; - - if (SUCCEEDED(CoInitialize(NULL))) - { - if (SUCCEEDED(CoCreateInstance((const CLSID *)&CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, (const IID *)&IID_ITaskbarList, (void**)&pTaskbarList))) - { - if (SUCCEEDED(pTaskbarList->lpVtbl->HrInit(pTaskbarList))) - { - if (show) - { - pTaskbarList->lpVtbl->AddTab(pTaskbarList,hWnd); - } - else - { - pTaskbarList->lpVtbl->DeleteTab(pTaskbarList,hWnd); - } - } - pTaskbarList->lpVtbl->Release(pTaskbarList); - } - CoUninitialize(); - } -} diff --git a/hw/xwin/wintrayicon.c b/hw/xwin/wintrayicon.c deleted file mode 100644 index 5d1e6aefa..000000000 --- a/hw/xwin/wintrayicon.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Early Ehlinger - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif - -#include "win.h" -#include <shellapi.h> -#include "winprefs.h" -#include "winclipboard/winclipboard.h" - -/* - * Initialize the tray icon - */ - -void -winInitNotifyIcon(winPrivScreenPtr pScreenPriv) -{ - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - NOTIFYICONDATA nid = { 0 }; - - 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; - - /* Set display and screen-specific tooltip text */ - snprintf(nid.szTip, - sizeof(nid.szTip), - PROJECT_NAME " Server:%s.%d", - display, (int) pScreenInfo->dwScreen); - - /* Add the tray icon */ - if (!Shell_NotifyIcon(NIM_ADD, &nid)) - ErrorF("winInitNotifyIcon - Shell_NotifyIcon Failed\n"); -} - -/* - * Delete the tray icon - */ - -void -winDeleteNotifyIcon(winPrivScreenPtr pScreenPriv) -{ - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - NOTIFYICONDATA nid = { 0 }; - -#if 0 - ErrorF("winDeleteNotifyIcon\n"); -#endif - - nid.cbSize = sizeof(NOTIFYICONDATA); - nid.hWnd = pScreenPriv->hwndScreen; - nid.uID = pScreenInfo->dwScreen; - - /* Delete the tray icon */ - if (!Shell_NotifyIcon(NIM_DELETE, &nid)) { - ErrorF("winDeleteNotifyIcon - Shell_NotifyIcon failed\n"); - return; - } - - /* Free the icon that was loaded */ - if (pScreenPriv->hiconNotifyIcon != NULL - && DestroyIcon(pScreenPriv->hiconNotifyIcon) == 0) { - ErrorF("winDeleteNotifyIcon - DestroyIcon failed\n"); - } - pScreenPriv->hiconNotifyIcon = NULL; -} - -/* - * Process messages intended for the tray icon - */ - -LRESULT -winHandleIconMessage(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam, winPrivScreenPtr pScreenPriv) -{ - winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - - switch (lParam) { - case WM_LBUTTONUP: - /* Restack and bring all windows to top */ - SetForegroundWindow (pScreenPriv->hwndScreen); - break; - - case WM_LBUTTONDBLCLK: - /* Display Exit dialog box */ - winDisplayExitDialog(pScreenPriv); - break; - - case WM_RBUTTONUP: - { - POINT ptCursor; - HMENU hmenuPopup; - HMENU hmenuTray; - - /* 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"); - - /* Get actual tray icon menu */ - hmenuTray = GetSubMenu(hmenuPopup, 0); - - /* 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 - { - /* Remove Hide Root Window button */ - RemoveMenu(hmenuTray, ID_APP_HIDE_ROOT, MF_BYCOMMAND); - } - - if (g_fClipboard) { - /* Set menu state to indicate if 'Monitor Primary' is enabled or not */ - MENUITEMINFO mii = { 0 }; - mii.cbSize = sizeof(MENUITEMINFO); - mii.fMask = MIIM_STATE; - mii.fState = fPrimarySelection ? MFS_CHECKED : MFS_UNCHECKED; - SetMenuItemInfo(hmenuTray, ID_APP_MONITOR_PRIMARY, FALSE, &mii); - } - else { - /* Remove 'Monitor Primary' menu item */ - RemoveMenu(hmenuTray, ID_APP_MONITOR_PRIMARY, MF_BYCOMMAND); - } - - SetupRootMenu(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; -} diff --git a/hw/xwin/winvalargs.c b/hw/xwin/winvalargs.c deleted file mode 100644 index 008c111a6..000000000 --- a/hw/xwin/winvalargs.c +++ /dev/null @@ -1,171 +0,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 "win.h" -#include "winmsg.h" - -/* - * Verify all screens have been explicitly specified - */ -static BOOL -isEveryScreenExplicit(void) -{ - int i; - - for (i = 0; i < g_iNumScreens; i++) - if (!g_ScreenInfo[i].fExplicitScreen) - return FALSE; - - return TRUE; -} - -/* - * winValidateArgs - Look for invalid argument combinations - */ - -Bool -winValidateArgs(void) -{ - int i; - BOOL fHasNormalScreen0 = 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 and -rootless. - */ - { - int iCount = 0; - - /* Count conflicting options */ - if (g_ScreenInfo[i].fMultiWindow) - ++iCount; - - 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 " - "and -rootless can be specific at a time.\n"); - return FALSE; - } - } - - /* Check for -multiwindow and Xdmcp */ - /* allow xdmcp if screen 0 is normal. */ - if (g_fXdmcpEnabled && !fHasNormalScreen0 && (FALSE - || g_ScreenInfo[i]. - fMultiWindow - - ) - ) { - ErrorF("winValidateArgs - Xdmcp (-query, -broadcast, or -indirect) " - "is invalid with -multiwindow.\n"); - return FALSE; - } - - /* Check for -multiwindow or -rootless and -fullscreen */ - if (g_ScreenInfo[i].fFullScreen && (FALSE - || g_ScreenInfo[i].fMultiWindow - || g_ScreenInfo[i].fRootless) - ) { - ErrorF("winValidateArgs - -fullscreen is invalid with " - "-multiwindow or -rootless.\n"); - return FALSE; - } - - /* Check for -multiwindow or -rootless and -nodecoration */ - if (!g_ScreenInfo[i].fDecoration && (FALSE - || g_ScreenInfo[i].fMultiWindow - || g_ScreenInfo[i].fRootless) - ) { - ErrorF("winValidateArgs - -nodecoration is invalid with " - "-multiwindow 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 != resizeNotAllowed) - || !g_ScreenInfo[i].fDecoration - || g_ScreenInfo[i].fLessPointer)) { - ErrorF("winValidateArgs - -fullscreen is invalid with " - "-scrollbars, -resize, -nodecoration, or -lesspointer.\n"); - return FALSE; - } - - /* Ignore -swcursor if -multiwindow -compositewm is requested */ - if (g_ScreenInfo[i].fMultiWindow && g_ScreenInfo[i].fCompositeWM) { - if (g_fSoftwareCursor) { - g_fSoftwareCursor = FALSE; - winMsg(X_WARNING, "Ignoring -swcursor due to -compositewm\n"); - } - } - } - - winDebug("winValidateArgs - Returning.\n"); - - return TRUE; -} diff --git a/hw/xwin/winwakeup.c b/hw/xwin/winwakeup.c deleted file mode 100644 index f593886ff..000000000 --- a/hw/xwin/winwakeup.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -/* See Porting Layer Definition - p. 7 */ -void -winWakeupHandler(ScreenPtr pScreen, int iResult) -{ - MSG msg; - - /* Process one message from our queue */ - if (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/hw/xwin/winwindow.c b/hw/xwin/winwindow.c deleted file mode 100644 index 934f6d845..000000000 --- a/hw/xwin/winwindow.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Harold L Hunt II - * Kensuke Matsuzaki - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" - -/* - * Prototypes for local functions - */ - -static int - winAddRgn(WindowPtr pWindow, void *data); - -static - void - winUpdateRgnRootless(WindowPtr pWindow); - -static - void - winReshapeRootless(WindowPtr pWin); - -/* See Porting Layer Definition - p. 37 */ -/* See mfb/mfbwindow.c - mfbCreateWindow() */ - -Bool -winCreateWindowRootless(WindowPtr pWin) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winCreateWindowRootless (%p)\n", pWin); -#endif - - 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) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winDestroyWindowRootless (%p)\n", pWin); -#endif - - 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; -} - -/* See Porting Layer Definition - p. 37 */ -/* See mfb/mfbwindow.c - mfbPositionWindow() */ - -Bool -winPositionWindowRootless(WindowPtr pWin, int x, int y) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winPositionWindowRootless (%p)\n", pWin); -#endif - - 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) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winChangeWindowAttributesRootless (%p)\n", pWin); -#endif - - WIN_UNWRAP(ChangeWindowAttributes); - fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask); - WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesRootless); - - winUpdateRgnRootless(pWin); - - return fResult; -} - -/* See Porting Layer Definition - p. 37 - * Also referred to as UnrealizeWindow - */ - -Bool -winUnmapWindowRootless(WindowPtr pWin) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winWindowPriv(pWin); - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winUnmapWindowRootless (%p)\n", pWin); -#endif - - 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; -} - -/* See Porting Layer Definition - p. 37 - * Also referred to as RealizeWindow - */ - -Bool -winMapWindowRootless(WindowPtr pWin) -{ - Bool fResult = FALSE; - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winMapWindowRootless (%p)\n", pWin); -#endif - - WIN_UNWRAP(RealizeWindow); - fResult = (*pScreen->RealizeWindow) (pWin); - WIN_WRAP(RealizeWindow, winMapWindowRootless); - - winReshapeRootless(pWin); - - winUpdateRgnRootless(pWin); - - return fResult; -} - -void -winSetShapeRootless(WindowPtr pWin, int kind) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - winScreenPriv(pScreen); - -#if CYGDEBUG - winTrace("winSetShapeRootless (%p, %i)\n", pWin, kind); -#endif - - 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, void *data) -{ - int iX, iY, iWidth, iHeight, iBorder; - HRGN hRgn = *(HRGN *) data; - HRGN hRgnWin; - - winWindowPriv(pWin); - - /* If pWin is not Root */ - if (pWin->parent != NULL) { -#if CYGDEBUG - winDebug("winAddRgn ()\n"); -#endif - 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) { - ErrorF("winAddRgn - CreateRectRgn () failed\n"); - ErrorF(" 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; - } -} - -/* - * Local function to update the Windows window's region - */ - -static - 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); - } - else { - ErrorF("winUpdateRgnRootless - CreateRectRgn failed.\n"); - } -} - -static - void -winReshapeRootless(WindowPtr pWin) -{ - int nRects; - RegionRec rrNewShape; - BoxPtr pShape, pRects, pEnd; - HRGN hRgn, hRgnRect; - - winWindowPriv(pWin); - -#if CYGDEBUG - winDebug("winReshapeRootless ()\n"); -#endif - - /* 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; - - /* 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); - } - - /* Save a handle to the composite region in the window privates */ - pWinPriv->hRgn = hRgn; - } - - RegionUninit(&rrNewShape); - - return; -} diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h deleted file mode 100644 index 92a839c4d..000000000 --- a/hw/xwin/winwindow.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - *Copyright (C) Colin Harrison 2005-2009 - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Kensuke Matsuzaki - * Colin Harrison - */ -#if !defined(_WINWINDOW_H_) -#define _WINWINDOW_H_ - -#ifndef NO -#define NO 0 -#endif -#ifndef YES -#define YES 1 -#endif - -/* Constant strings */ -#ifndef PROJECT_NAME -#define PROJECT_NAME "Cygwin/X" -#endif -#define EXECUTABLE_NAME "XWin" -#define WINDOW_CLASS "cygwin/x" -#define WINDOW_TITLE PROJECT_NAME ":%s.%d" -#define WINDOW_TITLE_XDMCP "%s:%s.%d" -#define WIN_SCR_PROP "cyg_screen_prop rl" -#define WINDOW_CLASS_X "cygwin/x X rl" -#define WINDOW_CLASS_X_MSG "cygwin/x X msg" -#define WINDOW_TITLE_X PROJECT_NAME " X" -#define WIN_WINDOW_PROP "cyg_window_prop_rl" -#ifdef HAS_DEVWINDOWS -#define WIN_MSG_QUEUE_FNAME "/dev/windows" -#endif -#define WIN_WID_PROP "cyg_wid_prop_rl" -#define WIN_NEEDMANAGE_PROP "cyg_override_redirect_prop_rl" -#ifndef CYGMULTIWINDOW_DEBUG -#define CYGMULTIWINDOW_DEBUG NO -#endif -#ifndef CYGWINDOWING_DEBUG -#define CYGWINDOWING_DEBUG NO -#endif - -#define XMING_SIGNATURE 0x12345678L - -typedef struct _winPrivScreenRec *winPrivScreenPtr; - -/* - * Window privates - */ - -typedef struct { - DWORD dwDummy; - HRGN hRgn; - HWND hWnd; - winPrivScreenPtr pScreenPriv; - Bool fXKilled; - HDWP hDwp; -#ifdef XWIN_GLX_WINDOWS - Bool fWglUsed; -#endif -} winPrivWinRec, *winPrivWinPtr; - -typedef struct _winWMMessageRec { - DWORD dwID; - DWORD msg; - int iWindow; - HWND hwndWindow; - int iX, iY; - int iWidth, iHeight; -} winWMMessageRec, *winWMMessagePtr; - -/* - * winmultiwindowwm.c - */ - -#define WM_WM_MOVE (WM_USER + 1) -#define WM_WM_SIZE (WM_USER + 2) -#define WM_WM_RAISE (WM_USER + 3) -#define WM_WM_LOWER (WM_USER + 4) -#define WM_WM_UNMAP (WM_USER + 6) -#define WM_WM_KILL (WM_USER + 7) -#define WM_WM_ACTIVATE (WM_USER + 8) -#define WM_WM_NAME_EVENT (WM_USER + 9) -#define WM_WM_ICON_EVENT (WM_USER + 10) -#define WM_WM_CHANGE_STATE (WM_USER + 11) -#define WM_WM_MAP_UNMANAGED (WM_USER + 12) -#define WM_WM_MAP_MANAGED (WM_USER + 13) -#define WM_WM_HINTS_EVENT (WM_USER + 14) - -#define MwmHintsDecorations (1L << 1) - -#define MwmDecorAll (1L << 0) -#define MwmDecorBorder (1L << 1) -#define MwmDecorHandle (1L << 2) -#define MwmDecorTitle (1L << 3) -#define MwmDecorMenu (1L << 4) -#define MwmDecorMinimize (1L << 5) -#define MwmDecorMaximize (1L << 6) - -/* - This structure only contains 3 elements. The Motif 2.0 structure contains 5, - but we only need the first 3, so that is all we will define - - This structure represents xcb_get_property()'s view of the property as a - sequence of ints, rather than XGetWindowProperty()'s view of the property as a - sequence of arch-dependent longs. -*/ -typedef struct MwmHints { - unsigned int flags, functions, decorations; -} MwmHints; - -#define PropMwmHintsElements 3 - -void - winSendMessageToWM(void *pWMInfo, winWMMessagePtr msg); - -Bool - -winInitWM(void **ppWMInfo, - pthread_t * ptWMProc, - pthread_t * ptXMsgProc, - pthread_mutex_t * ppmServerStarted, - int dwScreen, HWND hwndScreen, Bool compositeWM); - -void - winDeinitMultiWindowWM(void); - -void - winPropertyStoreInit(void); - -void - winPropertyStoreDestroy(void); - -void - winSetAppUserModelID(HWND hWnd, const char *AppID); - -void - winShowWindowOnTaskbar(HWND hWnd, Bool show); - -#endif diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c deleted file mode 100644 index c7950880f..000000000 --- a/hw/xwin/winwndproc.c +++ /dev/null @@ -1,1180 +0,0 @@ -/* - *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. - * - *Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - *"Software"), to deal in the Software without restriction, including - *without limitation the rights to use, copy, modify, merge, publish, - *distribute, sublicense, and/or sell copies of the Software, and to - *permit persons to whom the Software is furnished to do so, subject to - *the following conditions: - * - *The above copyright notice and this permission notice shall be - *included in all copies or substantial portions of the Software. - * - *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR - *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - *Except as contained in this notice, the name of the XFree86 Project - *shall not be used in advertising or otherwise to promote the sale, use - *or other dealings in this Software without prior written authorization - *from the XFree86 Project. - * - * Authors: Dakshinamurthy Karra - * Suhaib M Siddiqi - * Peter Busch - * Harold L Hunt II - * MATSUZAKI Kensuke - */ - -#ifdef HAVE_XWIN_CONFIG_H -#include <xwin-config.h> -#endif -#include "win.h" -#include <commctrl.h> -#include "winprefs.h" -#include "winconfig.h" -#include "winmsg.h" -#include "winmonitors.h" -#include "inputstr.h" -#include "winclipboard/winclipboard.h" - -/* - * Global variables - */ - -Bool g_fCursor = TRUE; -Bool g_fButton[3] = { FALSE, FALSE, FALSE }; - -/* - * Called by winWakeupHandler - * Processes current Windows message - */ - -LRESULT CALLBACK -winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - static winPrivScreenPtr s_pScreenPriv = NULL; - static winScreenInfo *s_pScreenInfo = NULL; - static ScreenPtr s_pScreen = NULL; - static HWND s_hwndLastPrivates = NULL; - static Bool s_fTracking = FALSE; - static unsigned long s_ulServerGeneration = 0; - static UINT s_uTaskbarRestart = 0; - int iScanCode; - int i; - -#if CYGDEBUG - winDebugWin32Message("winWindowProc", hwnd, message, wParam, lParam); -#endif - - /* 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) { -#if CYGDEBUG - winDebug("winWindowProc - Setting privates handle\n"); -#endif - s_pScreenInfo = s_pScreenPriv->pScreenInfo; - s_pScreen = s_pScreenInfo->pScreen; - s_hwndLastPrivates = hwnd; - } - else if (s_pScreenPriv == NULL) { - /* For safety, handle case that should never happen */ - s_pScreenInfo = NULL; - s_pScreen = NULL; - s_hwndLastPrivates = NULL; - } - - /* Branch on message type */ - switch (message) { - case WM_TRAYICON: - return winHandleIconMessage(hwnd, message, wParam, lParam, - s_pScreenPriv); - - case WM_CREATE: -#if CYGDEBUG - winDebug("winWindowProc - WM_CREATE\n"); -#endif - - /* - * 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_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); - } - return 0; - - case WM_DISPLAYCHANGE: - /* - WM_DISPLAYCHANGE seems to be sent when the monitor layout or - any monitor's resolution or depth changes, but its 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 initializing. 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_DDNL)) { - break; - } - - ErrorF("winWindowProc - WM_DISPLAYCHANGE - new width: %d " - "new height: %d new bpp: %d\n", - LOWORD(lParam), HIWORD(lParam), (int)wParam); - - /* 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_DDNL) { - /* Cannot display the visual until the depth is restored */ - ErrorF("winWindowProc - Disruptive change in depth\n"); - - /* Display depth change dialog */ - winDisplayDepthChangeDialog(s_pScreenPriv); - - /* Flag that we have an invalid screen depth */ - s_pScreenPriv->fBadDepth = TRUE; - - /* Minimize the display window */ - ShowWindow(hwnd, SW_MINIMIZE); - } - else { - /* 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; - } - - /* - 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) && (s_pScreenInfo-> - fRootless - || - s_pScreenInfo-> - fMultiWindow - )) { - DWORD dwWidth = 0, dwHeight = 0; - - 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)) { - 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); - } - } - - /* - 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 (((dwWidth != 0) && (dwHeight != 0)) && - ((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. - */ - - winDebug - ("winWindowProc - WM_DISPLAYCHANGE - Releasing and recreating primary surface\n"); - - /* Release the old primary surface */ - if (*s_pScreenPriv->pwinReleasePrimarySurface) - (*s_pScreenPriv->pwinReleasePrimarySurface) (s_pScreen); - - /* Create the new primary surface */ - if (*s_pScreenPriv->pwinCreatePrimarySurface) - (*s_pScreenPriv->pwinCreatePrimarySurface) (s_pScreen); - } - } - - break; - - case WM_SIZE: - { - SCROLLINFO si; - RECT rcWindow; - int iWidth, iHeight; - -#if CYGDEBUG - winDebug("winWindowProc - WM_SIZE\n"); -#endif - - /* Break if we do not allow resizing */ - if ((s_pScreenInfo->iResizeMode == resizeNotAllowed) - || !s_pScreenInfo->fDecoration - || s_pScreenInfo->fRootless - || s_pScreenInfo->fMultiWindow - || s_pScreenInfo->fFullScreen) - break; - - /* No need to resize if we get minimized */ - if (wParam == SIZE_MINIMIZED) - return 0; - - ErrorF("winWindowProc - WM_SIZE - new client area w: %d h: %d\n", - LOWORD(lParam), HIWORD(lParam)); - - 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; - - case WM_SYSCOMMAND: - if (s_pScreenInfo->iResizeMode == resizeWithRandr && - ((wParam & 0xfff0) == SC_MAXIMIZE || - (wParam & 0xfff0) == SC_RESTORE)) - PostMessage(hwnd, WM_EXITSIZEMOVE, 0, 0); - break; - - case WM_ENTERSIZEMOVE: - ErrorF("winWindowProc - WM_ENTERSIZEMOVE\n"); - break; - - case WM_EXITSIZEMOVE: - ErrorF("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; - - case WM_VSCROLL: - { - SCROLLINFO si; - int iVertPos; - -#if CYGDEBUG - winDebug("winWindowProc - WM_VSCROLL\n"); -#endif - - /* Get vertical scroll bar info */ - si.cbSize = sizeof(si); - si.fMask = SIF_ALL; - GetScrollInfo(hwnd, SB_VERT, &si); - - /* Save the vertical position for comparison later */ - iVertPos = si.nPos; - - /* - * Don't forget: - * moving the scrollbar to the DOWN, scroll the content UP - */ - switch (LOWORD(wParam)) { - case SB_TOP: - si.nPos = si.nMin; - break; - - case SB_BOTTOM: - si.nPos = si.nMax - si.nPage + 1; - break; - - case SB_LINEUP: - si.nPos -= 1; - break; - - case SB_LINEDOWN: - si.nPos += 1; - break; - - case SB_PAGEUP: - si.nPos -= si.nPage; - break; - - case SB_PAGEDOWN: - si.nPos += si.nPage; - break; - - case SB_THUMBTRACK: - si.nPos = si.nTrackPos; - break; - - default: - break; - } - - /* - * We retrieve the position after setting it, - * because Windows may adjust it. - */ - si.fMask = SIF_POS; - SetScrollInfo(hwnd, SB_VERT, &si, TRUE); - GetScrollInfo(hwnd, SB_VERT, &si); - - /* Scroll the window if the position has changed */ - if (si.nPos != iVertPos) { - /* Save the new offset for bit block transfers, etc. */ - s_pScreenInfo->dwYOffset = -si.nPos; - - /* Change displayed region in the window */ - ScrollWindowEx(hwnd, - 0, - iVertPos - si.nPos, - NULL, NULL, NULL, NULL, SW_INVALIDATE); - - /* Redraw the window contents */ - UpdateWindow(hwnd); - } - } - return 0; - - case WM_HSCROLL: - { - SCROLLINFO si; - int iHorzPos; - -#if CYGDEBUG - winDebug("winWindowProc - WM_HSCROLL\n"); -#endif - - /* Get horizontal scroll bar info */ - si.cbSize = sizeof(si); - si.fMask = SIF_ALL; - GetScrollInfo(hwnd, SB_HORZ, &si); - - /* Save the horizontal position for comparison later */ - iHorzPos = si.nPos; - - /* - * Don't forget: - * moving the scrollbar to the RIGHT, scroll the content LEFT - */ - switch (LOWORD(wParam)) { - case SB_LEFT: - si.nPos = si.nMin; - break; - - case SB_RIGHT: - si.nPos = si.nMax - si.nPage + 1; - break; - - case SB_LINELEFT: - si.nPos -= 1; - break; - - case SB_LINERIGHT: - si.nPos += 1; - break; - - case SB_PAGELEFT: - si.nPos -= si.nPage; - break; - - case SB_PAGERIGHT: - si.nPos += si.nPage; - break; - - case SB_THUMBTRACK: - si.nPos = si.nTrackPos; - break; - - default: - break; - } - - /* - * We retrieve the position after setting it, - * because Windows may adjust it. - */ - si.fMask = SIF_POS; - SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); - GetScrollInfo(hwnd, SB_HORZ, &si); - - /* Scroll the window if the position has changed */ - if (si.nPos != iHorzPos) { - /* Save the new offset for bit block transfers, etc. */ - s_pScreenInfo->dwXOffset = -si.nPos; - - /* Change displayed region in the window */ - ScrollWindowEx(hwnd, - iHorzPos - si.nPos, - 0, NULL, NULL, NULL, NULL, SW_INVALIDATE); - - /* Redraw the window contents */ - UpdateWindow(hwnd); - } - } - return 0; - - case WM_GETMINMAXINFO: - { - MINMAXINFO *pMinMaxInfo = (MINMAXINFO *) lParam; - int iCaptionHeight; - int iBorderHeight, iBorderWidth; - -#if CYGDEBUG - winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %p\n", - s_pScreenInfo); -#endif - - /* Can't do anything without screen info */ - if (s_pScreenInfo == NULL - || (s_pScreenInfo->iResizeMode != resizeWithScrollbars) - || s_pScreenInfo->fFullScreen || !s_pScreenInfo->fDecoration - || s_pScreenInfo->fRootless - || s_pScreenInfo->fMultiWindow - ) - 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: -#if CYGDEBUG - winDebug("winWindowProc - WM_ERASEBKGND\n"); -#endif - /* - * 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: -#if CYGDEBUG - winDebug("winWindowProc - WM_PAINT\n"); -#endif - /* 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: - { -#if CYGDEBUG - winDebug("winWindowProc - WM_PALETTECHANGED\n"); -#endif - /* - * Don't process if we don't have privates or a colormap, - * or if we have an invalid depth. - */ - if (s_pScreenPriv == NULL - || s_pScreenPriv->pcmapInstalled == NULL - || s_pScreenPriv->fBadDepth) - break; - - /* Return if we caused the palette to change */ - if ((HWND) wParam == hwnd) { - /* Redraw the screen */ - (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen); - return 0; - } - - /* Reinstall the windows palette */ - (*s_pScreenPriv->pwinRealizeInstalledPalette) (s_pScreen); - - /* Redraw the screen */ - (*s_pScreenPriv->pwinRedrawScreen) (s_pScreen); - return 0; - } - - case WM_MOUSEMOVE: - /* We can't do anything without privates */ - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - /* We can't do anything without g_pwinPointer */ - if (g_pwinPointer == NULL) - break; - - /* Has the mouse pointer crossed screens? */ - if (s_pScreen != miPointerGetScreen(g_pwinPointer)) - miPointerSetScreen(g_pwinPointer, s_pScreenInfo->dwScreen, - GET_X_LPARAM(lParam) - s_pScreenInfo->dwXOffset, - GET_Y_LPARAM(lParam) - s_pScreenInfo->dwYOffset); - - /* Are we tracking yet? */ - if (!s_fTracking) { - TRACKMOUSEEVENT tme; - - /* Setup data structure */ - ZeroMemory(&tme, sizeof(tme)); - tme.cbSize = sizeof(tme); - tme.dwFlags = TME_LEAVE; - tme.hwndTrack = hwnd; - - /* Call the tracking function */ - if (!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; - - case WM_MOUSELEAVE: - /* Mouse has left our client area */ - - /* Flag that we are no longer tracking */ - s_fTracking = FALSE; - - /* Show the mouse cursor, if necessary */ - if (g_fSoftwareCursor && !g_fCursor) { - g_fCursor = TRUE; - ShowCursor(TRUE); - } - return 0; - - case WM_LBUTTONDBLCLK: - case WM_LBUTTONDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - if (s_pScreenInfo->fRootless) - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button1, wParam); - - case WM_LBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - if (s_pScreenInfo->fRootless) - 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) - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button2, wParam); - - case WM_MBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - if (s_pScreenInfo->fRootless) - 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) - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, Button3, wParam); - - case WM_RBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - if (s_pScreenInfo->fRootless) - 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) - SetCapture(hwnd); - return winMouseButtonsHandle(s_pScreen, ButtonPress, HIWORD(wParam) + 7, - wParam); - case WM_XBUTTONUP: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - if (s_pScreenInfo->fRootless) - ReleaseCapture(); - return winMouseButtonsHandle(s_pScreen, ButtonRelease, - HIWORD(wParam) + 7, 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: - { - static POINT last_point; - 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); - - /* If the mouse pointer has moved, deliver absolute cursor position to X Server */ - if (last_point.x != point.x || last_point.y != point.y) { - winEnqueueMotion(point.x, point.y); - last_point.x = point.x; - last_point.y = point.y; - } - - /* Check if a button was released but we didn't see it */ - GetCursorPos(&point); - wL = (GetKeyState(VK_LBUTTON) & 0x8000) ? MK_LBUTTON : 0; - wM = (GetKeyState(VK_MBUTTON) & 0x8000) ? MK_MBUTTON : 0; - wR = (GetKeyState(VK_RBUTTON) & 0x8000) ? MK_RBUTTON : 0; - wShift = (GetKeyState(VK_SHIFT) & 0x8000) ? MK_SHIFT : 0; - wCtrl = (GetKeyState(VK_CONTROL) & 0x8000) ? MK_CONTROL : 0; - lPos = MAKELPARAM(point.x, point.y); - if (g_fButton[0] && !wL) - PostMessage(hwnd, WM_LBUTTONUP, wCtrl | wM | wR | wShift, lPos); - if (g_fButton[1] && !wM) - PostMessage(hwnd, WM_MBUTTONUP, wCtrl | wL | wR | wShift, lPos); - if (g_fButton[2] && !wR) - PostMessage(hwnd, WM_RBUTTONUP, wCtrl | wL | wM | wShift, lPos); - } - } - return 0; - - case WM_CTLCOLORSCROLLBAR: - FatalError("winWindowProc - WM_CTLCOLORSCROLLBAR - We are not " - "supposed to get this message. Exiting.\n"); - return 0; - - case WM_MOUSEWHEEL: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; -#if CYGDEBUG - winDebug("winWindowProc - WM_MOUSEWHEEL\n"); -#endif - /* Button4 = WheelUp */ - /* Button5 = WheelDown */ - winMouseWheel(&(s_pScreenPriv->iDeltaZ), GET_WHEEL_DELTA_WPARAM(wParam), Button4, Button5); - break; - - case WM_MOUSEHWHEEL: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; -#if CYGDEBUG - winDebug("winWindowProc - WM_MOUSEHWHEEL\n"); -#endif - /* Button7 = TiltRight */ - /* Button6 = TiltLeft */ - winMouseWheel(&(s_pScreenPriv->iDeltaV), GET_WHEEL_DELTA_WPARAM(wParam), 7, 6); - break; - - case WM_SETFOCUS: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - /* Restore the state of all mode keys */ - winRestoreModeKeyStates(); - - /* Add the keyboard hook if possible */ - if (g_fKeyboardHookLL) - g_fKeyboardHookLL = winInstallKeyboardHookLL(); - return 0; - - case WM_KILLFOCUS: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - /* Release any pressed keys */ - winKeybdReleaseKeys(); - - /* Remove our keyboard hook if it is installed */ - winRemoveKeyboardHookLL(); - return 0; - - case WM_SYSKEYDOWN: - case WM_KEYDOWN: - if (s_pScreenPriv == NULL || s_pScreenInfo->fIgnoreInput) - break; - - /* - * FIXME: Catching Alt-F4 like this is really terrible. This should - * be generalized to handle other Windows keyboard signals. Actually, - * the list keys to catch and the actions to perform when caught should - * be configurable; that way user's can customize the keys that they - * need to have passed through to their window manager or apps, or they - * can remap certain actions to new key codes that do not conflict - * with the X apps that they are using. Yeah, that'll take awhile. - */ - if ((s_pScreenInfo->fUseWinKillKey && wParam == VK_F4 - && (GetKeyState(VK_MENU) & 0x8000)) - || (s_pScreenInfo->fUseUnixKillKey && wParam == VK_BACK - && (GetKeyState(VK_MENU) & 0x8000) - && (GetKeyState(VK_CONTROL) & 0x8000))) { - /* - * Better leave this message here, just in case some unsuspecting - * user enters Alt + F4 and is surprised when the application - * quits. - */ - ErrorF("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; - break; - default: - return 0; - } - } - - /* Translate Windows key code to X scan code */ - iScanCode = winTranslateKey(wParam, lParam); - - /* 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 */ - iScanCode = winTranslateKey(wParam, lParam); - winSendKeyEvent(iScanCode, FALSE); - - /* Release all pressed shift keys */ - if (wParam == VK_SHIFT) - winFixShiftKeys(iScanCode); - 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) { - ErrorF("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; - } - -#if CYGDEBUG - winDebug("winWindowProc - WM_ACTIVATE\n"); -#endif - - /* - * 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; - s_pScreenPriv->iDeltaV = 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 CYGDEBUG || TRUE - winDebug("winWindowProc - WM_ACTIVATEAPP\n"); -#endif - - /* 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); - } - - /* Call engine specific screen activation/deactivation function */ - (*s_pScreenPriv->pwinActivateApp) (s_pScreen); - - return 0; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case ID_APP_EXIT: - /* Display Exit dialog */ - winDisplayExitDialog(s_pScreenPriv); - 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; - - case ID_APP_MONITOR_PRIMARY: - fPrimarySelection = !fPrimarySelection; - 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), s_pScreenPriv)) - return 0; - } - break; - - case WM_GIVEUP: - /* Tell X that we are giving up */ - if (s_pScreenInfo->fMultiWindow) - winDeinitMultiWindowWM(); - GiveUp(0); - return 0; - - case WM_CLOSE: - /* Display Exit dialog */ - winDisplayExitDialog(s_pScreenPriv); - return 0; - - case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT) { - if (!g_fSoftwareCursor) - SetCursor(s_pScreenPriv->cursor.handle); - return TRUE; - } - break; - - default: - if ((message == s_uTaskbarRestart) && !s_pScreenInfo->fNoTrayIcon) { - winInitNotifyIcon(s_pScreenPriv); - } - break; - } - - return DefWindowProc(hwnd, message, wParam, lParam); -} |