[xorg-commit-diffs] xc/programs/Xserver/hw/xwin winwin32rootless.c, 1.1.2.9, 1.1.2.10 winprefs.c, 1.1.6.9, 1.1.6.10 winmultiwindowwndproc.c, 1.1.6.16, 1.1.6.17 winmultiwindowwindow.c, 1.1.4.1.2.24, 1.1.4.1.2.25

Earle Philhower xorg-commit at pdx.freedesktop.org
Tue Apr 13 23:12:49 PDT 2004


Committed by: earle

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

Modified Files:
      Tag: CYGWIN
	winwin32rootless.c winprefs.c winmultiwindowwndproc.c 
	winmultiwindowwindow.c 
Log Message:
LoadImage() g_hiconX because it is DestroyIcon()d cannot use LoadIcon(). Fix off-by-one class naming problem. More error checking on icon and menu creation.


Index: winwin32rootless.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/Attic/winwin32rootless.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -d -r1.1.2.9 -r1.1.2.10
--- a/winwin32rootless.c	10 Apr 2004 23:18:09 -0000	1.1.2.9
+++ b/winwin32rootless.c	14 Apr 2004 06:12:44 -0000	1.1.2.10
@@ -257,7 +257,11 @@
     g_hiconX = (HICON)winOverrideDefaultIcon();
   
   if (!g_hiconX)
-    g_hiconX = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+    g_hiconX = (HICON)LoadImage (g_hInstance,
+				 MAKEINTRESOURCE(IDI_XWIN),
+				 IMAGE_ICON,
+				 0, 0,
+				 LR_DEFAULTSIZE);
   
   /* Try and get the icon from WM_HINTS */
   hIcon = winXIconToHICON (pFrame->win);

Index: winprefs.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winprefs.c,v
retrieving revision 1.1.6.9
retrieving revision 1.1.6.10
diff -u -d -r1.1.6.9 -r1.1.6.10
--- a/winprefs.c	25 Mar 2004 12:43:39 -0000	1.1.6.9
+++ b/winprefs.c	14 Apr 2004 06:12:44 -0000	1.1.6.10
@@ -82,7 +82,7 @@
   int i;
   int item;
   MENUPARSED *m;
-  HMENU hmenu;
+  HMENU hmenu, hsub;
 
   for (i=0; i<pref.menuItems; i++)
     {
@@ -107,6 +107,11 @@
   else
     {
       hmenu = CreatePopupMenu();
+      if (!hmenu)
+	{
+	  ErrorF("MakeMenu: Unable to CreatePopupMenu() %s\n", name);
+	  return NULL;
+	}
       item = 0;
     }
 
@@ -139,11 +144,13 @@
 	  
 	case CMD_MENU:
 	  /* Recursive! */
-	  InsertMenu (hmenu,
-		      item,
-		      MF_BYPOSITION|MF_POPUP|MF_ENABLED|MF_STRING,
-		      (UINT_PTR)MakeMenu (m->menuItem[i].param, 0, 0),
-		      m->menuItem[i].text);
+	  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;
 	}
 
@@ -165,6 +172,12 @@
 ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
 {
   HICON   hicon;
+  Window  wid;
+
+  if (!hwnd) {
+    ErrorF("ReloadEnumWindowsProc: hwnd==NULL!\n");
+    return FALSE;
+  }
 
   /* It's our baby, either clean or dirty it */
   if (lParam==FALSE) 
@@ -175,9 +188,10 @@
       SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (NULL, IDI_APPLICATION));
 
       /* If it's generated on-the-fly, get rid of it, will regen */
-      if (!winIconIsOverride((unsigned long)hicon) && hicon!=g_hiconX)
+      if (!winIconIsOverride((unsigned long)hicon) && (hicon!=g_hiconX))
 	DestroyIcon (hicon);
       
+      
       /* Remove any menu additions, use bRevert flag */
       GetSystemMenu (hwnd, TRUE);
       
@@ -185,9 +199,11 @@
     }
   else
     {
-      /* Make the icon default, dynamic, of from xwinrc */
+      /* Make the icon default, dynamic, or from xwinrc */
       SetClassLong (hwnd, GCL_HICON, (LONG)g_hiconX);
-      winUpdateIcon ((Window)GetProp (hwnd, WIN_WID_PROP));
+      wid = (Window)GetProp (hwnd, WIN_WID_PROP);
+      if (wid)
+	winUpdateIcon (wid);
       /* Update the system menu for this window */
       SetupSysMenu ((unsigned long)hwnd);
 
@@ -243,7 +259,8 @@
   pref.iconItems = 0;
   
   /* Free global default X icon */
-  DestroyIcon (g_hiconX);
+  if (g_hiconX)
+    DestroyIcon (g_hiconX);
 
   /* Reset the custom command IDs */
   g_cmdid = STARTMENUID;
@@ -253,8 +270,13 @@
 
   /* Define global icon, load it */
   g_hiconX = (HICON)winOverrideDefaultIcon();
+  /* Use LoadImage so we get a non-shared, safe-to-kill resource */
   if (!g_hiconX)
-    g_hiconX = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+    g_hiconX = (HICON)LoadImage (g_hInstance,
+				 MAKEINTRESOURCE(IDI_XWIN),
+				 IMAGE_ICON,
+				 0, 0,
+				 LR_DEFAULTSIZE);
   
 #ifdef XWIN_MULTIWINDOW
   /* Rebuild the icons and menus */
@@ -478,8 +500,8 @@
     {
       hicon = LoadImageComma (pref.defaultIconName, 0, 0, LR_DEFAULTSIZE);
       if (hicon==NULL)
-        ErrorF ("winOverrideDefaultIcon: LoadIcon(%s) failed\n",
-                 pref.defaultIconName);
+        ErrorF ("winOverrideDefaultIcon: LoadImageComma(%s) failed\n",
+		pref.defaultIconName);
 
       return (unsigned long)hicon;
     }
@@ -501,19 +523,19 @@
   if (pref.trayIconName[0])
     {
       hicon = LoadImageComma (pref.trayIconName,
-                             GetSystemMetrics (SM_CXSMICON),
-                             GetSystemMetrics (SM_CYSMICON),
-                             0 );
+			      GetSystemMetrics (SM_CXSMICON),
+			      GetSystemMetrics (SM_CYSMICON),
+			      0 );
     }
 
   /* Otherwise return the default */
   if (!hicon)
     hicon =  (HICON) LoadImage (g_hInstance,
-                               MAKEINTRESOURCE(IDI_XWIN),
-                               IMAGE_ICON,
-                               GetSystemMetrics (SM_CXSMICON),
-                               GetSystemMetrics (SM_CYSMICON),
-                               0);
+				MAKEINTRESOURCE(IDI_XWIN),
+				IMAGE_ICON,
+				GetSystemMetrics (SM_CXSMICON),
+				GetSystemMetrics (SM_CYSMICON),
+				0);
 
   return (unsigned long)hicon;
 }
@@ -623,7 +645,7 @@
 
        hicon = LoadImageComma (pref.icon[i].iconFile, 0, 0, LR_DEFAULTSIZE);
        if (hicon==NULL)
-         ErrorF ("winOverrideIcon: LoadIcon(%s) failed\n",
+         ErrorF ("winOverrideIcon: LoadImageComma(%s) failed\n",
                   pref.icon[i].iconFile);
 
 	pref.icon[i].hicon = (unsigned long)hicon;
@@ -695,11 +717,18 @@
       strcat (fname, ".XWinrc");
       
       prefFile = fopen (fname, "r");
+      if (prefFile)
+	ErrorF ("winPrefsLoadPreferences: %s\n", fname);
     }
 
   /* No home file found, check system default */
   if (!prefFile)
-    prefFile = fopen (PROJECTROOT"/lib/X11/system.XWinrc", "r");
+    {
+      prefFile = fopen (PROJECTROOT"/lib/X11/system.XWinrc", "r");
+      if (prefFile)
+	ErrorF ("winPrefsLoadPreferences: %s\n",
+		PROJECTROOT"/lib/X11/system.XWinrc");
+    }
 
   /* If we could open it, then read the settings and close it */
   if (prefFile)

Index: winmultiwindowwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwndproc.c,v
retrieving revision 1.1.6.16
retrieving revision 1.1.6.17
diff -u -d -r1.1.6.16 -r1.1.6.17
--- a/winmultiwindowwndproc.c	10 Apr 2004 23:18:09 -0000	1.1.6.16
+++ b/winmultiwindowwndproc.c	14 Apr 2004 06:12:44 -0000	1.1.6.17
@@ -41,7 +41,6 @@
  */
 
 extern Bool			g_fCursor;
-extern HICON			g_hiconX;
 extern Bool			g_fKeyboardHookLL;
 
 

Index: winmultiwindowwindow.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwindow.c,v
retrieving revision 1.1.4.1.2.24
retrieving revision 1.1.4.1.2.25
diff -u -d -r1.1.4.1.2.24 -r1.1.4.1.2.25
--- a/winmultiwindowwindow.c	10 Apr 2004 23:18:09 -0000	1.1.4.1.2.24
+++ b/winmultiwindowwindow.c	14 Apr 2004 06:12:44 -0000	1.1.4.1.2.25
@@ -500,7 +500,11 @@
     g_hiconX = (HICON)winOverrideDefaultIcon();
   
   if (!g_hiconX)
-    g_hiconX = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+    g_hiconX = (HICON)LoadImage (g_hInstance,
+				 MAKEINTRESOURCE(IDI_XWIN),
+				 IMAGE_ICON,
+				 0, 0,
+				 LR_DEFAULTSIZE);
   
   /* Try and get the icon from WM_HINTS */
   hIcon = winXIconToHICON (pWin);
@@ -510,7 +514,7 @@
     hIcon = g_hiconX;
 
   /* Set standard class name prefix so we can identify window easily */
-  strncpy (pszClass, WINDOW_CLASS_X, strlen (WINDOW_CLASS_X));
+  strncpy (pszClass, WINDOW_CLASS_X, sizeof(pszClass));
 
   if (winMultiWindowGetClassHint (pWin, &res_name, &res_class))
     {
@@ -601,7 +605,6 @@
  * winDestroyWindowsWindow - Destroy a Windows window associated
  * with an X window
  */
-
 static void
 winDestroyWindowsWindow (WindowPtr pWin)
 {
@@ -653,7 +656,7 @@
 #endif
       
       /* Only delete if it's not the default */
-      if (hiconClass != g_hiconX &&
+      if ((hiconClass != g_hiconX) &&
 	  !winIconIsOverride((unsigned long)hiconClass))
 	{ 
 	  iReturn = DestroyIcon (hiconClass);




More information about the xorg-commit-diffs mailing list