From: Rémi Bernon rbernon@codeweavers.com
--- dlls/desk.cpl/Makefile.in | 2 +- dlls/desk.cpl/desk.rc | 1 + dlls/desk.cpl/main.c | 38 ++++++++++++++++++++++++++++++++++++++ dlls/desk.cpl/resource.h | 1 + 4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/dlls/desk.cpl/Makefile.in b/dlls/desk.cpl/Makefile.in index 50ddb9b0125..fd267ac51af 100644 --- a/dlls/desk.cpl/Makefile.in +++ b/dlls/desk.cpl/Makefile.in @@ -1,5 +1,5 @@ MODULE = desk.cpl -IMPORTS = ole32 comctl32 user32 gdi32 +IMPORTS = advapi32 ole32 comctl32 user32 gdi32
SOURCES = \ desk.rc \ diff --git a/dlls/desk.cpl/desk.rc b/dlls/desk.cpl/desk.rc index dfffed3466c..da7deec665b 100644 --- a/dlls/desk.cpl/desk.rc +++ b/dlls/desk.cpl/desk.rc @@ -38,6 +38,7 @@ FONT 8, "Ms Shell Dlg" COMBOBOX IDC_DISPLAY_SETTINGS_LIST, 10, 136, 160, 60, CBS_DROPDOWNLIST | CBS_HASSTRINGS PUSHBUTTON "&Reset", IDC_DISPLAY_SETTINGS_RESET, 180, 135, 60, 15 PUSHBUTTON "&Apply", IDC_DISPLAY_SETTINGS_APPLY, 250, 135, 60, 15 + AUTOCHECKBOX "Emulate display mode changes (requires restart)", IDC_EMULATE_MODESET, 10, 155, 300, 10 }
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL diff --git a/dlls/desk.cpl/main.c b/dlls/desk.cpl/main.c index 7dad563be16..15ebbfde94f 100644 --- a/dlls/desk.cpl/main.c +++ b/dlls/desk.cpl/main.c @@ -242,6 +242,39 @@ static void handle_display_settings_apply(void) ChangeDisplaySettingsExW( NULL, NULL, 0, 0, NULL ); }
+static void handle_emulate_modeset_change( HWND hwnd ) +{ + const WCHAR *value = L"N"; + HKEY hkey; + + /* Registry key can be found in HKCU\Software\Wine\X11 Driver */ + if (!RegCreateKeyExW( HKEY_CURRENT_USER, L"Software\Wine\X11 Driver", 0, NULL, 0, + KEY_SET_VALUE, NULL, &hkey, NULL )) + { + if (IsDlgButtonChecked( hwnd, IDC_EMULATE_MODESET ) == BST_CHECKED) value = L"Y"; + RegSetValueExW( hkey, L"EmulateModeset", 0, REG_SZ, (BYTE *)value, (wcslen( value ) + 1) * sizeof(WCHAR) ); + RegCloseKey( hkey ); + } +} + +static BOOL get_option( const WCHAR *option, BOOL default_value ) +{ + BOOL ret = default_value; + WCHAR buffer[MAX_PATH]; + DWORD size = sizeof(buffer); + +#define IS_OPTION_TRUE(ch) \ + ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1') + + /* Registry key can be found in HKCU\Software\Wine\X11 Driver */ + if (!RegGetValueW( HKEY_CURRENT_USER, L"Software\Wine\X11 Driver", option, RRF_RT_REG_SZ, NULL, + (BYTE *)buffer, &size )) + ret = IS_OPTION_TRUE(buffer[0]); + +#undef IS_OPTION_TRUE + return ret; +} + static RECT map_virtual_client_rect( RECT rect, RECT client_rect, RECT virtual_rect, float scale ) { OffsetRect( &rect, -(virtual_rect.left + virtual_rect.right) / 2, -(virtual_rect.top + virtual_rect.bottom) / 2 ); @@ -424,6 +457,8 @@ static INT_PTR CALLBACK desktop_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, case WM_INITDIALOG: refresh_device_list( hwnd ); create_desktop_view( hwnd ); + SendMessageW( GetDlgItem( hwnd, IDC_EMULATE_MODESET ), BM_SETCHECK, + get_option( L"EmulateModeset", FALSE ), 0 ); return TRUE;
case WM_COMMAND: @@ -432,6 +467,9 @@ static INT_PTR CALLBACK desktop_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, case MAKEWPARAM( IDC_DISPLAY_SETTINGS_LIST, CBN_SELCHANGE ): handle_display_settings_change( hwnd ); break; + case IDC_EMULATE_MODESET: + handle_emulate_modeset_change( hwnd ); + break; case IDC_DISPLAY_SETTINGS_APPLY: handle_display_settings_apply(); break; diff --git a/dlls/desk.cpl/resource.h b/dlls/desk.cpl/resource.h index 03ff9c1e0b2..f16b9c724bd 100644 --- a/dlls/desk.cpl/resource.h +++ b/dlls/desk.cpl/resource.h @@ -40,5 +40,6 @@ #define IDC_DISPLAY_SETTINGS_LIST 2001 #define IDC_DISPLAY_SETTINGS_RESET 2002 #define IDC_DISPLAY_SETTINGS_APPLY 2003 +#define IDC_EMULATE_MODESET 2004
#define ICO_MAIN 100