[Winecfg] Remember previously stored Desktop setting (resend)

Lionel Ulmer lionel.ulmer at free.fr
Wed Nov 16 12:53:18 CST 2005


The previous patch was too ugly to go in ... but since then the 'check the
first letter' patch on the Desktop option got committed which gave me an
easy way to rewrite my patch :)

         Lionel

Changelog:
 - remember the desktop settings when disabling it

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: programs/winecfg/x11drvdlg.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/x11drvdlg.c,v
retrieving revision 1.26
diff -u -r1.26 x11drvdlg.c
--- programs/winecfg/x11drvdlg.c	18 Oct 2005 10:35:41 -0000	1.26
+++ programs/winecfg/x11drvdlg.c	16 Nov 2005 18:50:41 -0000
@@ -48,6 +48,20 @@
 
 int updating_ui;
 
+static void fill_gui_for_desktop_mode(HWND dialog, char *buf) {
+    char *bufindex = strchr(buf, 'x');
+    if (bufindex) {
+       *bufindex = 0;
+       ++bufindex;
+       SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
+       SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
+    } else {
+       WINE_TRACE("Desktop registry entry is malformed");
+       SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640");
+       SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480");
+    }
+}
+
 static void update_gui_for_desktop_mode(HWND dialog) {
     int desktopenabled = FALSE;
 
@@ -57,7 +71,7 @@
     /* do we have desktop mode enabled? */
     if (reg_key_exists(config_key, keypath("X11 Driver"), "Desktop"))
     {
-        char* buf, *bufindex;
+        char* buf;
 	CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
 
         buf = get_reg_key(config_key, keypath("X11 Driver"), "Desktop", "640x480");
@@ -70,20 +84,20 @@
             enable(IDC_DESKTOP_SIZE);
             enable(IDC_DESKTOP_BY);
 
-            bufindex = strchr(buf, 'x');
-            if (bufindex) {
-                *bufindex = 0;
-                ++bufindex;
-                SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
-                SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
-            } else {
-                WINE_TRACE("Desktop registry entry is malformed");
-                SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640");
-                SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480");
-            }
+	    fill_gui_for_desktop_mode(dialog, buf);
         }
+	else
+	{
+	    fill_gui_for_desktop_mode(dialog, buf + 1);
+	}
         HeapFree(GetProcessHeap(), 0, buf);
     }
+    else
+    {
+	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "");
+	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "");
+    }
+    
     if (!desktopenabled)
     {
 	CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_UNCHECKED);
@@ -92,9 +106,6 @@
 	disable(IDC_DESKTOP_HEIGHT);
 	disable(IDC_DESKTOP_SIZE);
 	disable(IDC_DESKTOP_BY);
-
-	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "");
-	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "");
     }
 
     updating_ui = FALSE;
@@ -180,7 +191,7 @@
     updating_ui = FALSE;
 }
 
-static void set_from_desktop_edits(HWND dialog) {
+static void set_from_desktop_edits(HWND dialog, BOOLEAN enabled) {
     char *width, *height, *new;
 
     if (updating_ui) return;
@@ -190,6 +201,14 @@
     width = get_text(dialog, IDC_DESKTOP_WIDTH);
     height = get_text(dialog, IDC_DESKTOP_HEIGHT);
 
+    if ((enabled == FALSE) &&
+	((width == NULL || strcmp(width, "") == 0) ||
+	 (height == NULL || strcmp(height, "") == 0)))
+    {
+        set_reg_key(config_key, keypath("X11 Driver"), "Desktop", NULL);
+	return;
+    }
+    
     if (width == NULL || strcmp(width, "") == 0) {
         HeapFree(GetProcessHeap(), 0, width);
         width = strdupA("640");
@@ -200,8 +219,8 @@
         height = strdupA("480");
     }
 
-    new = HeapAlloc(GetProcessHeap(), 0, strlen(width) + strlen(height) + 2 /* x + terminator */);
-    sprintf(new, "%sx%s", width, height);
+    new = HeapAlloc(GetProcessHeap(), 0, strlen(width) + strlen(height) + 2 /* x + terminator */ + ( enabled ? 0 : 1) /* leading F */ );
+    sprintf(new, "%s%sx%s", (enabled ? "" : "F"), width, height);
     set_reg_key(config_key, keypath("X11 Driver"), "Desktop", new);
     
     HeapFree(GetProcessHeap(), 0, width);
@@ -213,9 +232,9 @@
     WINE_TRACE("\n");
     
     if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
-        set_from_desktop_edits(dialog);
+        set_from_desktop_edits(dialog, TRUE);
     } else {
-        set_reg_key(config_key, keypath("X11 Driver"), "Desktop", NULL);
+	set_from_desktop_edits(dialog, FALSE);
     }
     
     update_gui_for_desktop_mode(dialog);
@@ -282,7 +301,7 @@
 		    if (updating_ui) break;
 		    SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
 		    if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updating_ui )
-			set_from_desktop_edits(hDlg);
+			set_from_desktop_edits(hDlg, TRUE);
 		    break;
 		}
 		case BN_CLICKED: {


More information about the wine-patches mailing list