winex11.drv: Set the refresh rate for the virtual desktop to 60
Jan Zerebecki
jan.wine at zerebecki.de
Fri Feb 23 02:27:15 CST 2007
If this patch is rejected from inclusion, please tell me why, as
I would have to ask anyway.
From: Jan Zerebecki <jan.wine at zerebecki.de>
Changelog:
winex11.drv: Set the refresh rate for the virtual desktop to 60
instead of 0. If HKCU\Software\Wine\X11 Driver\FakeRefreshRate is
set, it is interpreted as a comma delimited list of refresh rates
to use instead.
---
dlls/winex11.drv/desktop.c | 57 +++++++++++++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
index 8863472..46bbd58 100644
--- a/dlls/winex11.drv/desktop.c
+++ b/dlls/winex11.drv/desktop.c
@@ -19,11 +19,14 @@
*/
#include "config.h"
+#include <stdlib.h>
+#include <string.h>
#include <X11/cursorfont.h>
#include <X11/Xlib.h>
#include "wine/winuser16.h"
#include "win.h"
+#include "winreg.h"
#include "ddrawi.h"
#include "x11drv.h"
#include "wine/debug.h"
@@ -42,27 +45,32 @@ static const unsigned int heights[] = {200, 300, 384, 480, 600, 768, 864, 1024
#define NUM_DESKTOP_MODES (sizeof(widths) / sizeof(widths[0]))
/* create the mode structures */
-static void make_modes(void)
+static void make_modes(char * refresh_rates)
{
+ char *elem;
+ unsigned int refresh_rate;
int i;
- /* original specified desktop size */
- X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 0);
- for (i=0; i<NUM_DESKTOP_MODES; i++)
- {
- if ( (widths[i] <= max_width) && (heights[i] <= max_height) )
+
+ for(; ( elem = strsep(&refresh_rates, ",") ) && *elem && 0 <= ( refresh_rate = strtol(elem , NULL, 0) ); ) {
+ /* original specified desktop size */
+ X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, refresh_rate);
+ for (i=0; i<NUM_DESKTOP_MODES; i++)
{
- if ( ( (widths[i] != max_width) || (heights[i] != max_height) ) &&
- ( (widths[i] != screen_width) || (heights[i] != screen_height) ) )
+ if ( (widths[i] <= max_width) && (heights[i] <= max_height) )
{
- /* only add them if they are smaller than the root window and unique */
- X11DRV_Settings_AddOneMode(widths[i], heights[i], 0, 0);
+ if ( ( (widths[i] != max_width) || (heights[i] != max_height) ) &&
+ ( (widths[i] != screen_width) || (heights[i] != screen_height) ) )
+ {
+ /* only add them if they are smaller than the root window and unique */
+ X11DRV_Settings_AddOneMode(widths[i], heights[i], 0, refresh_rate);
+ }
}
}
- }
- if ((max_width != screen_width) && (max_height != screen_height))
- {
- /* root window size (if different from desktop window) */
- X11DRV_Settings_AddOneMode(max_width, max_height, 0, 0);
+ if ((max_width != screen_width) && (max_height != screen_height))
+ {
+ /* root window size (if different from desktop window) */
+ X11DRV_Settings_AddOneMode(max_width, max_height, 0, refresh_rate);
+ }
}
}
@@ -142,13 +150,28 @@ void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height )
screen_width = width;
screen_height = height;
xinerama_init();
+ HKEY hkey;
+ char buffer[64] = "60\0";
+ char buffer_copy[64];
+ int refresh_count = 0;
+ char *elem, *bufferp = buffer_copy;
+
+ /* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
+ if ( !RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver", &hkey ) ) {
+ DWORD count = sizeof(buffer);
+ RegQueryValueExA(hkey, "FakeRefreshRate", 0, NULL, (LPBYTE)buffer, &count);
+ RegCloseKey(hkey);
+ }
+ strcpy(buffer_copy, buffer);
+ for(; ( elem = strsep(&bufferp, ",") ) && *elem && 0 <= strtol(elem , NULL, 0); )
+ refresh_count++;
/* initialize the available resolutions */
dd_modes = X11DRV_Settings_SetHandlers("desktop",
X11DRV_desktop_GetCurrentMode,
X11DRV_desktop_SetCurrentMode,
- NUM_DESKTOP_MODES+2, 1);
- make_modes();
+ (NUM_DESKTOP_MODES+2)*refresh_count, 1);
+ make_modes(buffer);
X11DRV_Settings_AddDepthModes();
dd_mode_count = X11DRV_Settings_GetModeCount();
X11DRV_Settings_SetDefaultMode(0);
More information about the wine-patches
mailing list