diff options
author | Harold L Hunt II <huntharo@msu.edu> | 2004-03-27 19:54:22 +0000 |
---|---|---|
committer | Harold L Hunt II <huntharo@msu.edu> | 2004-03-27 19:54:22 +0000 |
commit | 1527162a67d7e9c763370f6e859e752be2317423 (patch) | |
tree | a9bcb4cc008ff38abce3e3bd7668fa0bec50da49 | |
parent | 4ece1336796ea1d1a86edc7a2acebcffec40a0e8 (diff) |
Clean up tray icon better, close clipboard down better, try to prevent
hangs in clipboard integration manager, fix bug with atoms not being
created if they did not already exist, and move About... entry in the
tray icon menu.
-rw-r--r-- | hw/xwin/InitOutput.c | 50 | ||||
-rw-r--r-- | hw/xwin/XWin.rc | 4 | ||||
-rw-r--r-- | hw/xwin/winclipboardthread.c | 47 | ||||
-rw-r--r-- | hw/xwin/winclipboardwndproc.c | 6 | ||||
-rwxr-xr-x | hw/xwin/winclipboardwrappers.c | 38 |
5 files changed, 118 insertions, 27 deletions
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index d0ae06dd5..9c829fe3d 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -77,6 +77,11 @@ extern FARPROC g_fpTrackMouseEvent; * Function prototypes */ +#ifdef XWIN_CLIPBOARD +static void +winClipboardShutdown (void); +#endif + #if defined(DDXOSVERRORF) void OsVendorVErrorF (const char *pszFormat, va_list va_args); @@ -122,30 +127,41 @@ static PixmapFormatRec g_PixmapFormats[] = { const int NUMFORMATS = sizeof (g_PixmapFormats) / sizeof (g_PixmapFormats[0]); -#if defined(DDXBEFORERESET) -/* - * Called right before KillAllClients when the server is going to reset, - * allows us to shutdown our seperate threads cleanly. - */ - -void -ddxBeforeReset (void) -{ - ErrorF ("ddxBeforeReset - Hello\n"); - #ifdef XWIN_CLIPBOARD +static void +winClipboardShutdown (void) +{ /* Close down clipboard resources */ if (g_fClipboard && g_fClipboardLaunched && g_fClipboardStarted) { /* Synchronously destroy the clipboard window */ if (g_hwndClipboard != NULL) SendMessage (g_hwndClipboard, WM_DESTROY, 0, 0); + else + return; /* Wait for the clipboard thread to exit */ pthread_join (g_ptClipboardProc, NULL); ErrorF ("ddxBeforeReset - Clipboard thread has exited.\n"); } +} +#endif + + +#if defined(DDXBEFORERESET) +/* + * Called right before KillAllClients when the server is going to reset, + * allows us to shutdown our seperate threads cleanly. + */ + +void +ddxBeforeReset (void) +{ + ErrorF ("ddxBeforeReset - Hello\n"); + +#ifdef XWIN_CLIPBOARD + winClipboardShutdown (); #endif } #endif @@ -155,10 +171,20 @@ ddxBeforeReset (void) void ddxGiveUp (void) { + int i; + #if CYGDEBUG winErrorFVerb (2, "ddxGiveUp\n"); #endif + /* Perform per-screen deinitialization */ + for (i = 0; i < g_iNumScreens; ++i) + { + /* Delete the tray icon */ + if (!g_ScreenInfo[i].fNoTrayIcon) + winDeleteNotifyIcon (winGetScreenPriv (g_ScreenInfo[i].pScreen)); + } + #ifdef XWIN_MULTIWINDOW /* Notify the worker threads we're exiting */ winDeinitMultiWindowWM (); @@ -510,7 +536,7 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[]) g_hInstance = GetModuleHandle (NULL); /* Initialize each screen */ - for (i = 0; i < g_iNumScreens; i++) + for (i = 0; i < g_iNumScreens; ++i) { /* Initialize the screen */ if (-1 == AddScreen (winScreenInit, argc, argv)) diff --git a/hw/xwin/XWin.rc b/hw/xwin/XWin.rc index d880691bc..a85e36c4b 100644 --- a/hw/xwin/XWin.rc +++ b/hw/xwin/XWin.rc @@ -38,7 +38,7 @@ /* About */ ABOUT_BOX DIALOG DISCARDABLE 32, 32, 240, 105 STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE | WS_TABSTOP | DS_CENTER -CAPTION "Cygwin/X - About" +CAPTION "About Cygwin/X" FONT 8, "MS Sans Serif" BEGIN CONTROL "Cygwin/X Website", ID_ABOUT_WEBSITE, "Button", @@ -93,9 +93,9 @@ BEGIN POPUP "TRAYICON_MENU" BEGIN MENUITEM "&Hide Root Window", ID_APP_HIDE_ROOT + MENUITEM "&About...", ID_APP_ABOUT MENUITEM SEPARATOR MENUITEM "E&xit", ID_APP_EXIT - MENUITEM "&About...", ID_APP_ABOUT END END diff --git a/hw/xwin/winclipboardthread.c b/hw/xwin/winclipboardthread.c index 31d215b0c..4987c99dd 100644 --- a/hw/xwin/winclipboardthread.c +++ b/hw/xwin/winclipboardthread.c @@ -84,12 +84,12 @@ winClipboardProc (void *pvNotUsed) Atom atomClipboard, atomClipboardManager; int iReturn; HWND hwnd = NULL; - int iConnectionNumber; - int fdMessageQueue; + int iConnectionNumber = 0; + int fdMessageQueue = 0; fd_set fdsRead; int iMaxDescriptor; - Display *pDisplay; - Window iWindow; + Display *pDisplay = NULL; + Window iWindow = None; int iRetries; Bool fUnicodeSupport; char szDisplay[512]; @@ -372,6 +372,45 @@ winClipboardProc (void *pvNotUsed) } } + /* Close our X window */ + if (pDisplay && iWindow) + { + iReturn = XDestroyWindow (pDisplay, iWindow); + if (iReturn == BadWindow) + ErrorF ("winClipboardProc - XDestroyWindow returned BadWindow.\n"); + else + ErrorF ("winClipboardProc - XDestroyWindow succeeded.\n"); + } + + /* Close our Win32 message handle */ + if (fdMessageQueue) + close (fdMessageQueue); + +#if 0 + /* + * FIXME: XCloseDisplay hangs if we call it, as of 2004/03/26. The + * XSync and XSelectInput calls did not help. + */ + + /* Discard any remaining events */ + XSync (pDisplay, TRUE); + + /* Select event types to watch */ + XSelectInput (pDisplay, + DefaultRootWindow (pDisplay), + None); + + /* Close our X display */ + if (pDisplay) + { + XCloseDisplay (pDisplay); + } +#endif + + g_iClipboardWindow = None; + g_pClipboardDisplay = NULL; + g_hwndClipboard = NULL; + return NULL; } diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c index f2950c1e6..feef1b9bb 100644 --- a/hw/xwin/winclipboardwndproc.c +++ b/hw/xwin/winclipboardwndproc.c @@ -201,7 +201,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, iReturn = XGetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", - FALSE)); + False)); if (iReturn == g_iClipboardWindow) { #if 0 @@ -211,7 +211,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", - FALSE), + False), None, CurrentTime); } @@ -244,7 +244,7 @@ winClipboardWindowProc (HWND hwnd, UINT message, iReturn = XSetSelectionOwner (pDisplay, XInternAtom (pDisplay, "CLIPBOARD", - FALSE), + False), iWindow, CurrentTime); if (iReturn == BadAtom || iReturn == BadWindow) diff --git a/hw/xwin/winclipboardwrappers.c b/hw/xwin/winclipboardwrappers.c index 33881e28c..59f0e2d0c 100755 --- a/hw/xwin/winclipboardwrappers.c +++ b/hw/xwin/winclipboardwrappers.c @@ -360,18 +360,28 @@ winProcSetSelectionOwner (ClientPtr client) && None != s_iOwners[CLIP_OWN_PRIMARY]) { fOwnedToNotOwned = TRUE; - + +#if 0 + ErrorF ("winProcSetSelectionOwner - PRIMARY - Going from " + "owned to not owned.\n"); +#endif + /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_CLIPBOARD]) - g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, FALSE); + g_atomLastOwnedSelection = MakeAtom ("CLIPBOARD", 9, TRUE); else g_atomLastOwnedSelection = None; } /* Save new selection owner or None */ s_iOwners[CLIP_OWN_PRIMARY] = stuff->window; + +#if 0 + ErrorF ("winProcSetSelectionOwner - PRIMARY - Now owned by: %d\n", + stuff->window); +#endif } - else if (MakeAtom ("CLIPBOARD", 9, FALSE) == stuff->selection) + else if (MakeAtom ("CLIPBOARD", 9, TRUE) == stuff->selection) { /* Look for owned -> not owned transition */ if (None == stuff->window @@ -379,7 +389,12 @@ winProcSetSelectionOwner (ClientPtr client) { fOwnedToNotOwned = TRUE; - /* Adjust last owned selection */ +#if 0 + ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Going from " + "owned to not owned.\n"); +#endif + + /* Adjust last owned selection */ if (None != s_iOwners[CLIP_OWN_PRIMARY]) g_atomLastOwnedSelection = XA_PRIMARY; else @@ -388,6 +403,11 @@ winProcSetSelectionOwner (ClientPtr client) /* Save new selection owner or None */ s_iOwners[CLIP_OWN_CLIPBOARD] = stuff->window; + +#if 0 + ErrorF ("winProcSetSelectionOwner - CLIPBOARD - Now owned by: %d\n", + stuff->window); +#endif } else goto winProcSetSelectionOwner_Done; @@ -401,8 +421,10 @@ winProcSetSelectionOwner (ClientPtr client) */ if (None == stuff->window && g_iClipboardWindow != client->lastDrawableID - && None == s_iOwners[CLIP_OWN_PRIMARY] - && None == s_iOwners[CLIP_OWN_CLIPBOARD] + && (None == s_iOwners[CLIP_OWN_PRIMARY] + || g_iClipboardWindow == s_iOwners[CLIP_OWN_PRIMARY]) + && (None == s_iOwners[CLIP_OWN_CLIPBOARD] + || g_iClipboardWindow == s_iOwners[CLIP_OWN_CLIPBOARD]) && fOwnedToNotOwned && g_hwndClipboard != NULL && g_hwndClipboard == GetClipboardOwner ()) @@ -418,6 +440,10 @@ winProcSetSelectionOwner (ClientPtr client) OpenClipboard (NULL); EmptyClipboard (); CloseClipboard (); + + /* Clear X selection ownership (might still be marked as us owning) */ + s_iOwners[CLIP_OWN_PRIMARY] = None; + s_iOwners[CLIP_OWN_CLIPBOARD] = None; goto winProcSetSelectionOwner_Done; } |