[xorg-commit-diffs] xc/programs/Xserver/hw/xwin InitOutput.c, 1.1.4.1.2.27, 1.1.4.1.2.28 XWin.rc, 1.1.4.1.2.8, 1.1.4.1.2.9 winclipboardthread.c, 1.1.4.1.2.13, 1.1.4.1.2.14 winclipboardwndproc.c, 1.1.4.1.2.13, 1.1.4.1.2.14 winclipboardwrappers.c, 1.1.2.13, 1.1.2.14

Harold L Hunt II xorg-commit at pdx.freedesktop.org
Sun Mar 28 19:48:26 PST 2004


Committed by: harold

Update of /cvs/xorg/xc/programs/Xserver/hw/xwin
In directory pdx:/tmp/cvs-serv19362

Modified Files:
      Tag: CYGWIN
	InitOutput.c XWin.rc winclipboardthread.c 
	winclipboardwndproc.c winclipboardwrappers.c 
Log Message:
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.

Index: InitOutput.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/InitOutput.c,v
retrieving revision 1.1.4.1.2.27
retrieving revision 1.1.4.1.2.28
diff -u -d -r1.1.4.1.2.27 -r1.1.4.1.2.28
--- a/InitOutput.c	17 Mar 2004 20:31:50 -0000	1.1.4.1.2.27
+++ b/InitOutput.c	27 Mar 2004 19:54:22 -0000	1.1.4.1.2.28
@@ -77,6 +77,11 @@
  * 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 @@
 
 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 @@
 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 @@
   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))

Index: XWin.rc
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/XWin.rc,v
retrieving revision 1.1.4.1.2.8
retrieving revision 1.1.4.1.2.9
diff -u -d -r1.1.4.1.2.8 -r1.1.4.1.2.9
--- a/XWin.rc	27 Mar 2004 06:49:07 -0000	1.1.4.1.2.8
+++ b/XWin.rc	27 Mar 2004 19:54:22 -0000	1.1.4.1.2.9
@@ -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 @@
 	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
 

Index: winclipboardthread.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardthread.c,v
retrieving revision 1.1.4.1.2.13
retrieving revision 1.1.4.1.2.14
diff -u -d -r1.1.4.1.2.13 -r1.1.4.1.2.14
--- a/winclipboardthread.c	26 Mar 2004 20:07:03 -0000	1.1.4.1.2.13
+++ b/winclipboardthread.c	27 Mar 2004 19:54:22 -0000	1.1.4.1.2.14
@@ -84,12 +84,12 @@
   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 @@
 	}
     }
 
+  /* 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;
 }
 

Index: winclipboardwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winclipboardwndproc.c,v
retrieving revision 1.1.4.1.2.13
retrieving revision 1.1.4.1.2.14
diff -u -d -r1.1.4.1.2.13 -r1.1.4.1.2.14
--- a/winclipboardwndproc.c	26 Mar 2004 19:45:21 -0000	1.1.4.1.2.13
+++ b/winclipboardwndproc.c	27 Mar 2004 19:54:22 -0000	1.1.4.1.2.14
@@ -201,7 +201,7 @@
 	    iReturn = XGetSelectionOwner (pDisplay,
 					  XInternAtom (pDisplay,
 						       "CLIPBOARD",
-						       FALSE));
+						       False));
 	    if (iReturn == g_iClipboardWindow)
 	      {
 #if 0
@@ -211,7 +211,7 @@
 		XSetSelectionOwner (pDisplay,
 				    XInternAtom (pDisplay,
 						 "CLIPBOARD",
-						 FALSE),
+						 False),
 				    None,
 				    CurrentTime);
 	      }
@@ -244,7 +244,7 @@
 	iReturn = XSetSelectionOwner (pDisplay,
 				      XInternAtom (pDisplay,
 						   "CLIPBOARD",
-						   FALSE),
+						   False),
 				      iWindow,
 				      CurrentTime);
 	if (iReturn == BadAtom || iReturn == BadWindow)

Index: winclipboardwrappers.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winclipboardwrappers.c,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -u -d -r1.1.2.13 -r1.1.2.14
--- a/winclipboardwrappers.c	3 Mar 2004 03:08:59 -0000	1.1.2.13
+++ b/winclipboardwrappers.c	27 Mar 2004 19:54:22 -0000	1.1.2.14
@@ -360,18 +360,28 @@
 	  && 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 @@
 	{
 	  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 @@
       
       /* 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 @@
    */
   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 @@
       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;
     }




More information about the xorg-commit-diffs mailing list