[WINECFG] Remember disabled Desktop settings

Lionel Ulmer lionel.ulmer at free.fr
Sun Oct 9 07:34:29 CDT 2005


As I often switch between Desktop and non-Desktop mode, I found it annoying
to each time having to re-enter my preferred 'Desktop' settings of 800x600.
So created the 'DesktopDisabled' key.

I find this a bit ugly as it would be best to save this in a
'winecfg'-specific registry hierarchy... But as doing this is much more work
and would need a bit of discussion on wine-devel, I still did it the 'ugly
way' (was 5 minutes to code) to trigger the discussion (and hope that this
patch will still be included :-) ).

Changelog:
 - remember Desktop settings between 'winecfg' invocations

       Lionel

-- 
		 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.25
diff -u -r1.25 x11drvdlg.c
--- programs/winecfg/x11drvdlg.c	26 Sep 2005 09:51:48 -0000	1.25
+++ programs/winecfg/x11drvdlg.c	9 Oct 2005 12:29:33 -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) {
     WINE_TRACE("\n");
 
@@ -56,7 +70,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);
 	
 	enable(IDC_DESKTOP_WIDTH);
@@ -65,18 +79,7 @@
 	enable(IDC_DESKTOP_BY);
 
         buf = get_reg_key(config_key, keypath("X11 Driver"), "Desktop", "640x480");
-        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);
         HeapFree(GetProcessHeap(), 0, buf);
     }
     else
@@ -88,8 +91,17 @@
 	disable(IDC_DESKTOP_SIZE);
 	disable(IDC_DESKTOP_BY);
 
-	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "");
-	SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "");
+	if (reg_key_exists(config_key, keypath("X11 Driver"), "DesktopDisabled"))
+	{
+	    char *buf = get_reg_key(config_key, keypath("X11 Driver"), "DesktopDisabled", "640x480");
+	    fill_gui_for_desktop_mode(dialog, buf);
+	    HeapFree(GetProcessHeap(), 0, buf);
+	}
+	else
+	{
+	    SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "");
+	    SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "");
+	}
     }
 
     updating_ui = FALSE;
@@ -175,7 +187,7 @@
     updating_ui = FALSE;
 }
 
-static void set_from_desktop_edits(HWND dialog) {
+static void set_from_desktop_edits(HWND dialog, char *key_name) {
     char *width, *height, *new;
 
     if (updating_ui) return;
@@ -197,7 +209,7 @@
 
     new = HeapAlloc(GetProcessHeap(), 0, strlen(width) + strlen(height) + 2 /* x + terminator */);
     sprintf(new, "%sx%s", width, height);
-    set_reg_key(config_key, keypath("X11 Driver"), "Desktop", new);
+    set_reg_key(config_key, keypath("X11 Driver"), key_name, new);
     
     HeapFree(GetProcessHeap(), 0, width);
     HeapFree(GetProcessHeap(), 0, height);
@@ -208,9 +220,11 @@
     WINE_TRACE("\n");
     
     if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
-        set_from_desktop_edits(dialog);
+        set_from_desktop_edits(dialog, "Desktop");
+	set_reg_key(config_key, keypath("X11 Driver"), "DesktopDisabled", NULL);
     } else {
         set_reg_key(config_key, keypath("X11 Driver"), "Desktop", NULL);
+	set_from_desktop_edits(dialog, "DesktopDisabled");
     }
     
     update_gui_for_desktop_mode(dialog);
@@ -277,7 +291,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, "Desktop");
 		    break;
 		}
 		case BN_CLICKED: {


More information about the wine-patches mailing list