diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index f646de4da..926469011 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,9 +1,70 @@ +2004-10-28 Alexander Gottwald + + * win.h: + add fRetryCreateSurface + * winshaddnl.c (winBltExposedRegionsShadowDDNL): + try to recreate the primary surface if it was lost + * winshaddnl.c (winCreatePrimarySurfaceShadowDDNL): + mark screen to retry creating the primary surface if it failed + +2004-10-23 Alexander Gottwald + + * winconfig (winConfigFiles): + Simplify /etc/X11/font-dirs parsing + +2004-10-20 Alexander Gottwald + + * XWin.rc, winresource.h, winwndproc.c: + Add ShowCursor entry to tray menu + +2004-10-20 Alexander Gottwald + + * Imakefile: + Add ETCX11DIR to DEFINES + * InitOutput.c (InitOutput): + * winconfig.c (winConfigFiles) : + Add entries from /etc/X11/font-dirs to default fontpath + +2004-10-16 Alexander Gottwald + + * winprocarg.c (winInitializeDefaultScreens, ddxProcessArgument): + * win.h: + Make multiple monitors default for -multiwindow and -mwextwm. + Added a flag to indicate if the user has overridden the multimonitor + settings. (Øyvind Harboe, Alexander Gottwald) + 2004-10-07 Torrey Lyons * winscrinit.c: Add compatibility with the generic rootless layer's new DoReorderWindow function. +2004-10-05 Alexander Gottwald + + * XWin.rc: + Set the dialogstyle to DS_CENTERMOUSE. Dialogs will now popup on the + monitor where the mouse is and not on the center of the whole desktop. + +2004-10-02 Alexander Gottwald + + * winmouse.c (winMouseProc): + Make sure buttons 1-3 are mouse buttons and wheel events are 4-5 + Document code + Replace ErrorF with appropriate winMsg + use a symbolic name for the wheel event offset + +2004-10-01 Alexander Gottwald + + * wincreatewnd.c (winCreateBoundingWindowWindowed): + Do not adjust workarea if native windowmanager is used + +2004-09-22 Kensuke Matsuzaki + + * winclipboardthread.c (winClipboardErrorHandler): + * winclipboardwndproc.c (winClipboardWindowProc): + * winclipboardxevents.c (winClipboardFlushXEvents): + Fix clipboard bug with unicode applications. + 2004-09-17 Torrey Lyons * winscrinit.c: (winFinishScreenInitFB): diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 673a0aa98..78e2bc70d 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -30,9 +30,7 @@ from The Open Group. #include "win.h" #include "winmsg.h" -#ifdef XWIN_XF86CONFIG #include "winconfig.h" -#endif #include "winprefs.h" #include "X11/Xlocale.h" #include @@ -635,6 +633,7 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) winMsg(X_INFO, "XF86Config 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 */ diff --git a/hw/xwin/XWin.rc b/hw/xwin/XWin.rc index 446174f64..dcde0b52d 100644 --- a/hw/xwin/XWin.rc +++ b/hw/xwin/XWin.rc @@ -37,7 +37,7 @@ /* About */ ABOUT_BOX DIALOG DISCARDABLE 32, 32, 240, 105 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTER +STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE CAPTION "About Cygwin/X" FONT 8, "MS Sans Serif" BEGIN @@ -59,7 +59,7 @@ END /* Depth change */ DEPTH_CHANGE_BOX DIALOG DISCARDABLE 32, 32, 180, 100 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTER +STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | DS_CENTERMOUSE FONT 8, "MS Sans Serif" CAPTION "Cygwin/X" BEGIN @@ -73,7 +73,7 @@ END /* Exit */ EXIT_DIALOG DIALOG DISCARDABLE 32, 32, 180, 78 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTER +STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTERMOUSE FONT 8, "MS Sans Serif" CAPTION "Cygwin/X - Exit?" BEGIN @@ -94,6 +94,7 @@ BEGIN POPUP "TRAYICON_MENU" BEGIN MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT + MENUITEM "Show Cursor", ID_APP_SHOWCURSOR MENUITEM "&About...", ID_APP_ABOUT MENUITEM SEPARATOR MENUITEM "E&xit", ID_APP_EXIT diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 33e874f1c..8fd8d21af 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -424,6 +424,9 @@ typedef struct Bool fRootless; #ifdef XWIN_MULTIWINDOW Bool fMultiWindow; +#endif +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) + Bool fMultiMonitorOverride; #endif Bool fMultipleMonitors; Bool fLessPointer; @@ -508,6 +511,7 @@ typedef struct _winPrivScreenRec LPDIRECTDRAW4 pdd4; LPDIRECTDRAWSURFACE4 pddsShadow4; LPDIRECTDRAWSURFACE4 pddsPrimary4; + BOOL fRetryCreateSurface; /* Privates used by both shadow fb DirectDraw servers */ LPDIRECTDRAWCLIPPER pddcPrimary; diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 0996b43f5..4778d2a3b 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -429,8 +429,12 @@ winClipboardErrorHandler (Display *pDisplay, XErrorEvent *pErr) pErr->error_code, pszErrorMsg, sizeof (pszErrorMsg)); - ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n", pszErrorMsg); - + ErrorF ("winClipboardErrorHandler - ERROR: \n\t%s\n" + "\tSerial: %d, Request Code: %d, Minor Code: %d\n", + pszErrorMsg, + pErr->serial, + pErr->request_code, + pErr->minor_code); return 0; } diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c index 722141924..cfc97a51b 100644 --- a/hw/xwin/winclipboardwndproc.c +++ b/hw/xwin/winclipboardwndproc.c @@ -44,6 +44,7 @@ */ extern Bool g_fUseUnicode; +extern Bool g_fUnicodeSupport; extern void *g_pClipboardDisplay; extern Window g_iClipboardWindow; extern Atom g_atomLastOwnedSelection; @@ -445,7 +446,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, if (message == WM_RENDERALLFORMATS) fConvertToUnicode = FALSE; else - fConvertToUnicode = g_fUseUnicode && (CF_UNICODETEXT == wParam); + fConvertToUnicode = g_fUnicodeSupport && (CF_UNICODETEXT == wParam); /* Request the selection contents */ iReturn = XConvertSelection (pDisplay, @@ -521,10 +522,9 @@ winClipboardWindowProc (HWND hwnd, UINT message, if (WIN_XEVENTS_NOTIFY != iReturn) { /* Paste no data, to satisfy required call to SetClipboardData */ - if (fConvertToUnicode) + if (g_fUnicodeSupport) SetClipboardData (CF_UNICODETEXT, NULL); - else - SetClipboardData (CF_TEXT, NULL); + SetClipboardData (CF_TEXT, NULL); } /* Special handling for WM_RENDERALLFORMATS */ diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c index 3d4444168..6a6d8ad2e 100644 --- a/hw/xwin/winclipboardxevents.c +++ b/hw/xwin/winclipboardxevents.c @@ -135,8 +135,8 @@ winClipboardFlushXEvents (HWND hwnd, iReturn = XChangeProperty (pDisplay, event.xselectionrequest.requestor, event.xselectionrequest.property, - event.xselectionrequest.target, - sizeof (atomTargetArr[0]), + XA_ATOM, + 32, PropModeReplace, (unsigned char *) atomTargetArr, (sizeof (atomTargetArr) diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c index 8660c5ab9..b8c773268 100644 --- a/hw/xwin/winconfig.c +++ b/hw/xwin/winconfig.c @@ -730,6 +730,127 @@ winConfigFiles () return TRUE; } +#else +Bool +winConfigFiles () +{ + MessageType from; + + /* Fontpath */ + from = X_DEFAULT; + + if (g_cmdline.fontPath) + { + from = X_CMDLINE; + defaultFontPath = g_cmdline.fontPath; + } + else + { + /* 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 defautl fontpath */ + char *fontpath = xstrdup(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); + from = X_CONFIG; + defaultFontPath = xstrdup(fontpath); + free(fontpath); + } + } + winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath); + + return TRUE; +} #endif diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c index 606da2e02..4c74f89e2 100644 --- a/hw/xwin/wincreatewnd.c +++ b/hw/xwin/wincreatewnd.c @@ -271,20 +271,30 @@ winCreateBoundingWindowWindowed (ScreenPtr pScreen) /* We cannot have scrollbars if we do not have a window border */ pScreenInfo->fScrollbars = FALSE; } + + if (TRUE +#ifdef XWIN_MULTIWINDOWEXTWM + && !pScreenInfo->fMWExtWM +#endif +#ifdef XWIN_MULTIWINDOW + && !pScreenInfo->fMultiWindow +#endif + ) + { + /* Trim window width to fit work area */ + if (iWidth > (rcWorkArea.right - rcWorkArea.left)) + iWidth = rcWorkArea.right - rcWorkArea.left; - /* 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; + /* 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); + winDebug ("winCreateBoundingWindowWindowed - Adjusted width: %d "\ + "height: %d\n", + iWidth, iHeight); #endif + } /* Set display and screen-specific tooltip text */ if (g_pszQueryHost != NULL) diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c index 6411d7989..93b38acd4 100644 --- a/hw/xwin/winmouse.c +++ b/hw/xwin/winmouse.c @@ -65,21 +65,39 @@ int winMouseProc (DeviceIntPtr pDeviceInt, int iState) { int lngMouseButtons, i; + int lngWheelEvents = 2; CARD8 *map; DevicePtr pDevice = (DevicePtr) pDeviceInt; switch (iState) { case DEVICE_INIT: + /* Get number of mouse buttons */ lngMouseButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); - ErrorF ("%d mouse buttons found\n", lngMouseButtons); - map = malloc(sizeof(CARD8) * (lngMouseButtons + 1 + 2)); - - for (i=1; i <= lngMouseButtons + 2; i++) + + /* Mapping of windows events to X events: + * LEFT:1 MIDDLE:2 RIGHT:3 + * SCROLL_UP:4 SCROLL_DOWN:5 + * XBUTTON 1:6 XBUTTON 2:7 ... + * + * To map scroll wheel correctly we need at least the 3 normal buttons + */ + if (lngMouseButtons < 3) + lngMouseButtons = 3; + winMsg(X_PROBED, "%d mouse buttons found\n", lngMouseButtons); + + /* allocate memory: + * number of buttons + 2x mouse wheel event + 1 extra (offset for map) + */ + map = malloc(sizeof(CARD8) * (lngMouseButtons + lngWheelEvents + 1)); + + /* initalize button map */ + map[0] = 0; + for (i=1; i <= lngMouseButtons + lngWheelEvents; i++) map[i] = i; InitPointerDeviceStruct (pDevice, map, - lngMouseButtons + 2, /* Buttons 4 and 5 are mouse wheel events */ + lngMouseButtons + lngWheelEvents, miPointerGetMotionEvents, winMouseCtrl, miPointerGetMotionBufferSize ()); diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index 0032a9152..dd61b94b5 100755 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -127,6 +127,9 @@ winInitializeDefaultScreens (void) g_ScreenInfo[i].fRootless = FALSE; #ifdef XWIN_MULTIWINDOW g_ScreenInfo[i].fMultiWindow = FALSE; +#endif +#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) + g_ScreenInfo[i].fMultiMonitorOverride = FALSE; #endif g_ScreenInfo[i].fMultipleMonitors = FALSE; g_ScreenInfo[i].fLessPointer = FALSE; @@ -399,12 +402,16 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + if (!g_ScreenInfo[j].fMultiMonitorOverride) + g_ScreenInfo[j].fMultipleMonitors = FALSE; g_ScreenInfo[j].fFullScreen = TRUE; } } else { /* Parameter is for a single screen */ + if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE; } @@ -451,12 +458,16 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + if (!g_ScreenInfo[j].fMultiMonitorOverride) + g_ScreenInfo[j].fMultipleMonitors = FALSE; g_ScreenInfo[j].fDecoration = FALSE; } } else { /* Parameter is for a single screen */ + if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; g_ScreenInfo[g_iLastScreen].fDecoration = FALSE; } @@ -478,12 +489,16 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + if (!g_ScreenInfo[j].fMultiMonitorOverride) + g_ScreenInfo[j].fMultipleMonitors = TRUE; g_ScreenInfo[j].fMWExtWM = TRUE; } } else { /* Parameter is for a single screen */ + if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE; } @@ -505,12 +520,16 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + if (!g_ScreenInfo[j].fMultiMonitorOverride) + g_ScreenInfo[j].fMultipleMonitors = FALSE; g_ScreenInfo[j].fRootless = TRUE; } } else { /* Parameter is for a single screen */ + if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; g_ScreenInfo[g_iLastScreen].fRootless = TRUE; } @@ -532,12 +551,16 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + if (!g_ScreenInfo[j].fMultiMonitorOverride) + g_ScreenInfo[j].fMultipleMonitors = TRUE; g_ScreenInfo[j].fMultiWindow = TRUE; } } else { /* Parameter is for a single screen */ + if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE; } @@ -560,12 +583,14 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Parameter is for all screens */ for (j = 0; j < MAXSCREENS; j++) { + g_ScreenInfo[j].fMultiMonitorOverride = TRUE; g_ScreenInfo[j].fMultipleMonitors = TRUE; } } else { /* Parameter is for a single screen */ + g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; } @@ -573,6 +598,36 @@ ddxProcessArgument (int argc, char *argv[], int i) return 1; } + /* + * Look for the '-nomultiplemonitors' argument + */ + if (IS_OPTION ("-nomultiplemonitors") + || IS_OPTION ("-nomultimonitors")) + { + /* Is this parameter attached to a screen or is it global? */ + if (-1 == g_iLastScreen) + { + int j; + + /* Parameter is for all screens */ + for (j = 0; j < MAXSCREENS; j++) + { + g_ScreenInfo[j].fMultiMonitorOverride = TRUE; + g_ScreenInfo[j].fMultipleMonitors = FALSE; + } + } + else + { + /* Parameter is for a single screen */ + g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; + g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; + } + + /* Indicate that we have processed this argument */ + return 1; + } + + /* * Look for the '-scrollbars' argument */ diff --git a/hw/xwin/winresource.h b/hw/xwin/winresource.h index 300fcd198..ca69521a1 100644 --- a/hw/xwin/winresource.h +++ b/hw/xwin/winresource.h @@ -48,6 +48,7 @@ #define ID_APP_HIDE_ROOT 201 #define ID_APP_ALWAYS_ON_TOP 202 #define ID_APP_ABOUT 203 +#define ID_APP_SHOWCURSOR 204 #define ID_ABOUT_UG 300 #define ID_ABOUT_FAQ 301 diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c index c9e629298..2ec28c957 100644 --- a/hw/xwin/winshadddnl.c +++ b/hw/xwin/winshadddnl.c @@ -141,11 +141,21 @@ winCreatePrimarySurfaceShadowDDNL (ScreenPtr pScreen) &ddsd, &pScreenPriv->pddsPrimary4, NULL); + pScreenPriv->fRetryCreateSurface = FALSE; if (FAILED (ddrval)) { - ErrorF ("winCreatePrimarySurfaceShadowDDNL - Could not create primary " - "surface: %08x\n", - (unsigned int) 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; } @@ -1055,6 +1065,17 @@ winBltExposedRegionsShadowDDNL (ScreenPtr pScreen) 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) diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c index aac3153bf..6188425dd 100644 --- a/hw/xwin/winwndproc.c +++ b/hw/xwin/winwndproc.c @@ -1161,6 +1161,9 @@ winWindowProc (HWND hwnd, UINT message, /* Display Exit dialog */ winDisplayExitDialog (s_pScreenPriv); return 0; + case ID_APP_SHOWCURSOR: + winDebug("ShowCursor: %d\n", ShowCursor(TRUE)); + return 0; #ifdef XWIN_MULTIWINDOW case ID_APP_HIDE_ROOT: