PATCH: XRandR part 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is the second part of this patch, containing the modifications to existing files.

-ajp
? dlls/x11drv/settings.c
? dlls/x11drv/xrandr.c
? dlls/x11drv/xrandr.h
Index: dlls/x11drv/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/Makefile.in,v
retrieving revision 1.31
diff -u -r1.31 Makefile.in
--- dlls/x11drv/Makefile.in	13 Jun 2003 23:26:02 -0000	1.31
+++ dlls/x11drv/Makefile.in	11 Oct 2003 17:55:31 -0000
@@ -32,11 +32,13 @@
 	keyboard.c \
 	mouse.c \
 	scroll.c \
+	settings.c \
 	ts_xlib.c \
 	window.c \
 	winpos.c \
 	x11ddraw.c \
 	x11drv_main.c \
+	xrandr.c \
 	xrender.c \
 	xvidmode.c
 
Index: dlls/x11drv/desktop.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/desktop.c,v
retrieving revision 1.15
diff -u -r1.15 desktop.c
--- dlls/x11drv/desktop.c	30 Sep 2003 00:31:42 -0000	1.15
+++ dlls/x11drv/desktop.c	11 Oct 2003 17:55:31 -0000
@@ -115,43 +115,22 @@
 
 /* data for resolution changing */
 static LPDDHALMODEINFO dd_modes;
-static int nmodes;
+static unsigned int dd_mode_count;
 
 static unsigned int max_width;
 static unsigned int max_height;
 
 static const unsigned int widths[]  = {320, 512, 640, 800, 1024, 1152, 1280, 1600};
 static const unsigned int heights[] = {200, 384, 480, 600,  768,  864, 1024, 1200};
-static const unsigned int depths[]  = {8, 16, 32};
-
-/* fill in DD mode info for one mode*/
-static void make_one_mode (LPDDHALMODEINFO info, unsigned int width, unsigned int height, unsigned int bpp)
-{
-    info->dwWidth        = width;
-    info->dwHeight       = height;
-    info->wRefreshRate   = 0;
-    info->lPitch         = 0;
-    info->dwBPP          = bpp;
-    info->wFlags         = 0;
-    info->dwRBitMask     = 0;
-    info->dwGBitMask     = 0;
-    info->dwBBitMask     = 0;
-    info->dwAlphaBitMask = 0;
-    TRACE("initialized mode %d: %dx%dx%d\n", nmodes, width, height, bpp);
-}
+#define NUM_DESKTOP_MODES (8)
 
 /* create the mode structures */
 static void make_modes(void)
 {
-    int i,j;
-    int max_modes = (3+1)*(8+2);
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    nmodes = 0;
-    dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * max_modes);
+    int i;
     /* original specified desktop size */
-    make_one_mode(&dd_modes[nmodes++], screen_width, screen_height, dwBpp);
-    for (i=0; i<8; i++)
+    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) )
         {
@@ -159,25 +138,14 @@
                  ( (widths[i] != screen_width) || (heights[i] != screen_height) ) )
             {
                 /* only add them if they are smaller than the root window and unique */
-                make_one_mode(&dd_modes[nmodes++], widths[i], heights[i], dwBpp);
+                X11DRV_Settings_AddOneMode(widths[i], heights[i], 0, 0);
             }
         }
     }
     if ((max_width != screen_width) && (max_height != screen_height))
     {
         /* root window size (if different from desktop window) */
-        make_one_mode(&dd_modes[nmodes++], max_width, max_height, dwBpp);
-    }
-    max_modes = nmodes;
-    for (j=0; j<3; j++)
-    {
-        if (depths[j] != dwBpp)
-        {
-            for (i=0; i < max_modes; i++)
-            {
-                make_one_mode(&dd_modes[nmodes++], dd_modes[i].dwWidth, dd_modes[i].dwHeight, depths[j]);
-            }
-        }
+        X11DRV_Settings_AddOneMode(max_width, max_height, 0, 0);
     }
 }
 
@@ -224,6 +192,33 @@
     return 1;
 }
 
+int X11DRV_desktop_GetCurrentMode(void)
+{
+    int i;
+    DWORD dwBpp = screen_depth;
+    if (dwBpp == 24) dwBpp = 32;
+    for (i=0; i<dd_mode_count; i++)
+    {
+        if ( (screen_width == dd_modes[i].dwWidth) &&
+             (screen_height == dd_modes[i].dwHeight) && 
+             (dwBpp == dd_modes[i].dwBPP))
+            return i;
+    }
+    ERR("In unknown mode, returning default\n");
+    return 0;
+}
+
+void X11DRV_desktop_SetCurrentMode(int mode)
+{
+    DWORD dwBpp = screen_depth;
+    if (dwBpp == 24) dwBpp = 32;
+    TRACE("Resizing Wine desktop window to %ldx%ld\n", dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
+    X11DRV_resize_desktop(dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
+    if (dwBpp != dd_modes[mode].dwBPP)
+    {
+        FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP);
+    }
+}
 
 /***********************************************************************
  *		X11DRV_create_desktop
@@ -297,145 +292,14 @@
     XFlush( display );
     wine_tsx11_unlock();
     /* initialize the available resolutions */
+    dd_modes = X11DRV_Settings_SetHandlers("desktop", 
+                                           X11DRV_desktop_GetCurrentMode, 
+                                           X11DRV_desktop_SetCurrentMode, 
+                                           NUM_DESKTOP_MODES+2, 1);
     make_modes();
+    X11DRV_Settings_AddDepthModes();
+    dd_mode_count = X11DRV_Settings_GetModeCount();
+    X11DRV_Settings_SetDefaultMode(0);
     return win;
 }
 
-void X11DRV_desktop_SetCurrentMode(int mode)
-{
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    if (mode < nmodes)
-    {
-        TRACE("Resizing Wine desktop window to %ldx%ld\n", dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
-        X11DRV_resize_desktop(dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
-        if (dwBpp != dd_modes[mode].dwBPP)
-        {
-            FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP);
-        }
-    }
-}
-
-int X11DRV_desktop_GetCurrentMode(void)
-{
-    int i;
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    for (i=0; i<nmodes; i++)
-    {
-        if ( (screen_width == dd_modes[i].dwWidth) &&
-             (screen_height == dd_modes[i].dwHeight) && 
-             (dwBpp == dd_modes[i].dwBPP))
-            return i;
-    }
-    ERR("In unknown mode, returning default\n");
-    return 0;
-}
-
-/* ChangeDisplaySettings and related functions */
-
-/* implementation of EnumDisplaySettings for desktop */
-BOOL X11DRV_desktop_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags)
-{
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    devmode->dmDisplayFlags = 0;
-    devmode->dmDisplayFrequency = 85;
-    devmode->dmSize = sizeof(DEVMODEW);
-    if (n==(DWORD)-1)
-    {
-        devmode->dmBitsPerPel = dwBpp;
-        devmode->dmPelsHeight = screen_height;
-        devmode->dmPelsWidth  = screen_width;
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
-        TRACE("mode %ld (current) -- returning current %ldx%ldx%ldbpp\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
-        return TRUE;
-    }
-    else if (n==(DWORD)-2)
-    {
-        devmode->dmBitsPerPel = dwBpp;
-        devmode->dmPelsHeight = dd_modes[0].dwHeight;
-        devmode->dmPelsWidth  = dd_modes[0].dwWidth;
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
-        TRACE("mode %ld (registry) -- returning default %ldx%ldx%ldbpp\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
-        return TRUE;
-    } 
-    else if (n < nmodes)
-    {
-        devmode->dmPelsWidth = dd_modes[n].dwWidth;
-        devmode->dmPelsHeight = dd_modes[n].dwHeight;
-        devmode->dmBitsPerPel = dd_modes[n].dwBPP;
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
-        TRACE("mode %ld -- %ldx%ldx%ldbpp\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
-        return TRUE;
-    }
-    TRACE("mode %ld -- not present\n", n);
-    return FALSE;
-}
-
-/* implementation of ChangeDisplaySettings for desktop */
-LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
-                                      HWND hwnd, DWORD flags, LPVOID lpvoid )
-{
-    DWORD i;
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    if (devmode==NULL)
-    {
-        X11DRV_desktop_SetCurrentMode(0);
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-
-    for (i = 0; i < nmodes; i++)
-    {
-        if (devmode->dmFields & DM_BITSPERPEL)
-        {
-            if (devmode->dmBitsPerPel != dd_modes[i].dwBPP)
-                continue;
-        }
-        if (devmode->dmFields & DM_PELSWIDTH)
-        {
-            if (devmode->dmPelsWidth != dd_modes[i].dwWidth)
-                continue;
-        }
-        if (devmode->dmFields & DM_PELSHEIGHT)
-        {
-            if (devmode->dmPelsHeight != dd_modes[i].dwHeight)
-                continue;
-        }
-        /* we have a valid mode */
-        TRACE("Requested display settings match mode %ld\n", i);
-        X11DRV_desktop_SetCurrentMode(i);
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-
-    /* no valid modes found */
-    ERR("No matching mode found!\n");
-    return DISP_CHANGE_BADMODE;
-}
-
-/* DirectDraw HAL stuff */
-
-static DWORD PASCAL X11DRV_desktop_SetMode(LPDDHAL_SETMODEDATA data)
-{
-    TRACE("Mode %ld requested by DDHAL\n", data->dwModeIndex);
-    X11DRV_desktop_SetCurrentMode(data->dwModeIndex);
-    X11DRV_DDHAL_SwitchMode(data->dwModeIndex, NULL, NULL);
-    data->ddRVal = DD_OK;
-    return DDHAL_DRIVER_HANDLED;
-}
-
-int X11DRV_desktop_CreateDriver(LPDDHALINFO info)
-{
-    if (!nmodes) return 0; /* no desktop */
-
-    TRACE("Setting up Desktop mode for DDRAW\n");
-    info->dwNumModes = nmodes;
-    info->lpModeInfo = dd_modes;
-    X11DRV_DDHAL_SwitchMode(X11DRV_desktop_GetCurrentMode(), NULL, NULL);
-    info->lpDDCallbacks->SetMode = X11DRV_desktop_SetMode;
-    return TRUE;
-}
Index: dlls/x11drv/x11ddraw.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11ddraw.c,v
retrieving revision 1.20
diff -u -r1.20 x11ddraw.c
--- dlls/x11drv/x11ddraw.c	16 Sep 2003 20:24:29 -0000	1.20
+++ dlls/x11drv/x11ddraw.c	11 Oct 2003 17:55:31 -0000
@@ -28,6 +28,7 @@
 #include "x11drv.h"
 #include "x11ddraw.h"
 #include "xvidmode.h"
+#include "xrandr.h"
 #include "dga2.h"
 
 #include "windef.h"
@@ -382,12 +383,7 @@
       if (!X11DRV_XF86DGA2_CreateDriver(&hal_info))
 #endif
       {
-#ifdef HAVE_LIBXXF86VM
-	if (!X11DRV_XF86VM_CreateDriver(&hal_info))
-#endif
-          {
-            X11DRV_desktop_CreateDriver(&hal_info);
-          }
+          X11DRV_Settings_CreateDriver(&hal_info);
       }
 #ifdef HAVE_OPENGL
       /*X11DRV_GLX_CreateDriver(&hal_info);*/
Index: dlls/x11drv/x11drv.h
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv.h,v
retrieving revision 1.5
diff -u -r1.5 x11drv.h
--- dlls/x11drv/x11drv.h	16 Sep 2003 20:24:29 -0000	1.5
+++ dlls/x11drv/x11drv.h	11 Oct 2003 17:55:32 -0000
@@ -491,13 +491,22 @@
 extern void X11DRV_X_to_window_rect( WND *win, RECT *rect );
 extern void X11DRV_create_desktop_thread(void);
 extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
-extern int X11DRV_desktop_CreateDriver(LPDDHALINFO info);
-extern BOOL X11DRV_desktop_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags);
-extern LONG X11DRV_desktop_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
-                                                     HWND hwnd, DWORD flags, LPVOID lpvoid );
 extern void X11DRV_sync_window_style( Display *display, WND *win );
 extern int X11DRV_sync_whole_window_position( Display *display, WND *win, int zorder );
 extern int X11DRV_sync_client_window_position( Display *display, WND *win );
 extern void X11DRV_set_wm_hints( Display *display, WND *win );
+
+extern void X11DRV_Settings_AddDepthModes(void);
+extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq);
+extern int X11DRV_Settings_CreateDriver(LPDDHALINFO info);
+extern LPDDHALMODEINFO X11DRV_Settings_CreateModes(unsigned int max_modes, int reserve_depths);
+unsigned int X11DRV_Settings_GetModeCount(void);
+void X11DRV_Settings_Init(void);
+extern void X11DRV_Settings_SetDefaultMode(int mode);
+LPDDHALMODEINFO X11DRV_Settings_SetHandlers(const char *name, 
+                                            int (*pNewGCM)(void), 
+                                            void (*pNewSCM)(int), 
+                                            unsigned int nmodes, 
+                                            int reserve_depths);
 
 #endif  /* __WINE_X11DRV_H */
Index: dlls/x11drv/x11drv_main.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/x11drv_main.c,v
retrieving revision 1.74
diff -u -r1.74 x11drv_main.c
--- dlls/x11drv/x11drv_main.c	27 Sep 2003 02:34:07 -0000	1.74
+++ dlls/x11drv/x11drv_main.c	11 Oct 2003 17:55:32 -0000
@@ -48,6 +48,7 @@
 #include "win.h"
 #include "x11drv.h"
 #include "xvidmode.h"
+#include "xrandr.h"
 #include "dga2.h"
 #include "wine/server.h"
 #include "wine/debug.h"
@@ -70,7 +71,7 @@
 unsigned int screen_depth;
 Window root_window;
 DWORD desktop_tid = 0;
-int dxgrab, usedga, usexvidmode;
+int dxgrab, usedga, usexvidmode, usexrandr;
 int use_xkb = 1;
 int use_take_focus = 1;
 int managed_mode = 1;
@@ -261,6 +262,9 @@
     if (!get_config_key( hkey, appkey, "UseXVidMode", buffer, sizeof(buffer) ))
         usexvidmode = IS_OPTION_TRUE( buffer[0] );
 
+    if (!get_config_key( hkey, appkey, "UseXRandR", buffer, sizeof(buffer) ))
+        usexrandr = IS_OPTION_TRUE( buffer[0] );
+
     if (!get_config_key( hkey, appkey, "UseTakeFocus", buffer, sizeof(buffer) ))
         use_take_focus = IS_OPTION_TRUE( buffer[0] );
 
@@ -361,6 +365,8 @@
     screen_width  = WidthOfScreen( screen );
     screen_height = HeightOfScreen( screen );
 
+    X11DRV_Settings_Init();
+
     if (desktop_geometry)
         root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
 
@@ -381,6 +387,10 @@
 #ifdef HAVE_LIBXXF86VM
     /* initialize XVidMode */
     X11DRV_XF86VM_Init();
+#endif
+#ifdef HAVE_LIBXRANDR
+    /* initialize XRandR */
+    X11DRV_XRandR_Init();
 #endif
 #ifdef HAVE_LIBXXF86DGA2
     /* initialize DGA2 */
Index: dlls/x11drv/xvidmode.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/xvidmode.c,v
retrieving revision 1.23
diff -u -r1.23 xvidmode.c
--- dlls/x11drv/xvidmode.c	30 Sep 2003 00:31:42 -0000	1.23
+++ dlls/x11drv/xvidmode.c	11 Oct 2003 17:55:32 -0000
@@ -28,7 +28,6 @@
 #define XMD_H
 #include "basetsd.h"
 #include <X11/extensions/xf86vmode.h>
-#endif  /* HAVE_LIBXXF86VM */
 #include "x11drv.h"
 
 #include "x11ddraw.h"
@@ -39,9 +38,7 @@
 #include "ddrawi.h"
 #include "wine/debug.h"
 
-WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
-
-#ifdef HAVE_LIBXXF86VM
+WINE_DEFAULT_DEBUG_CHANNEL(xvidmode);
 
 extern int usexvidmode;
 
@@ -50,31 +47,22 @@
 #ifdef X_XF86VidModeSetGammaRamp
 static int xf86vm_gammaramp_size;
 static BOOL xf86vm_use_gammaramp;
-#endif
+#endif /* X_XF86VidModeSetGammaRamp */
 
 static LPDDHALMODEINFO dd_modes;
 static unsigned int dd_mode_count;
 static XF86VidModeModeInfo** real_xf86vm_modes;
 static unsigned int real_xf86vm_mode_count;
-static unsigned int xf86vm_initial_mode;
+static unsigned int xf86vm_initial_mode = 0;
 
-static void convert_modeinfo( const XF86VidModeModeInfo *mode, LPDDHALMODEINFO info, unsigned int bpp)
+static void convert_modeinfo( const XF86VidModeModeInfo *mode)
 {
-  info->dwWidth      = mode->hdisplay;
-  info->dwHeight     = mode->vdisplay;
+  int rate;
   if (mode->htotal!=0 && mode->vtotal!=0)
-      info->wRefreshRate = mode->dotclock * 1000 / (mode->htotal * mode->vtotal);
+      rate = mode->dotclock * 1000 / (mode->htotal * mode->vtotal);
   else
-      info->wRefreshRate = 0;
-  TRACE(" width=%ld, height=%ld, refresh=%d\n",
-        info->dwWidth, info->dwHeight, info->wRefreshRate);
-  info->lPitch         = 0;
-  info->dwBPP          = bpp;
-  info->wFlags         = 0;
-  info->dwRBitMask     = 0;
-  info->dwGBitMask     = 0;
-  info->dwBBitMask     = 0;
-  info->dwAlphaBitMask = 0;
+      rate = 0;
+  X11DRV_Settings_AddOneMode(mode->hdisplay, mode->vdisplay, 0, rate);
 }
 
 static void convert_modeline(int dotclock, const XF86VidModeModeLine *mode, LPDDHALMODEINFO info, unsigned int bpp)
@@ -102,13 +90,64 @@
 }
 
 static Bool in_desktop_mode;
-static const unsigned int depths[]  = {8, 16, 32};
+
+int X11DRV_XF86VM_GetCurrentMode(void)
+{
+  XF86VidModeModeLine line;
+  int dotclock, i;
+  DDHALMODEINFO cmode;
+  DWORD dwBpp = screen_depth;
+  if (dwBpp == 24) dwBpp = 32;
+
+  TRACE("Querying XVidMode current mode\n");
+  wine_tsx11_lock();
+  XF86VidModeGetModeLine(gdi_display, DefaultScreen(gdi_display), &dotclock, &line);
+  wine_tsx11_unlock();
+  convert_modeline(dotclock, &line, &cmode, dwBpp);
+  for (i=0; i<dd_mode_count; i++)
+    if (memcmp(&dd_modes[i], &cmode, sizeof(cmode)) == 0) {
+      TRACE("mode=%d\n", i);
+      return i;
+    }
+  ERR("In unknown mode, returning default\n");
+  return xf86vm_initial_mode;
+}
+
+void X11DRV_XF86VM_SetCurrentMode(int mode)
+{
+  DWORD dwBpp = screen_depth;
+  if (dwBpp == 24) dwBpp = 32;
+  /* only set modes from the original color depth */
+  if (dwBpp != dd_modes[mode].dwBPP)
+  {
+      FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP);
+  }
+  mode = mode % real_xf86vm_mode_count;
+
+  wine_tsx11_lock();
+  TRACE("Resizing X display to %dx%d\n", 
+        real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
+  XF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), real_xf86vm_modes[mode]);
+#if 0 /* FIXME */
+  SYSMETRICS_Set( SM_CXSCREEN, real_xf86vm_modes[mode]->hdisplay );
+  SYSMETRICS_Set( SM_CYSCREEN, real_xf86vm_modes[mode]->vdisplay );
+#else
+  FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n",
+        real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
+#endif
+#if 0 /* it is said that SetViewPort causes problems with some X servers */
+  XF86VidModeSetViewPort(gdi_display, DefaultScreen(gdi_display), 0, 0);
+#else
+  XWarpPointer(gdi_display, None, DefaultRootWindow(gdi_display), 0, 0, 0, 0, 0, 0);
+#endif
+  XSync(gdi_display, False);
+  wine_tsx11_unlock();
+}
 
 void X11DRV_XF86VM_Init(void)
 {
   Bool ok;
-  int nmodes, i, j;
-  int max_modes;
+  int nmodes, i;
   DWORD dwBpp = screen_depth;
   if (dwBpp == 24) dwBpp = 32;
 
@@ -137,7 +176,7 @@
           if (xf86vm_gammaramp_size == 256)
               xf86vm_use_gammaramp = TRUE;
       }
-#endif
+#endif /* X_XF86VidModeSetGammaRamp */
 
       /* retrieve modes */
       if (!in_desktop_mode) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
@@ -151,32 +190,27 @@
   TRACE("XVidMode modes: count=%d\n", nmodes);
 
   real_xf86vm_mode_count = nmodes;
-  max_modes = (3+1)*(nmodes);
 
-  dd_modes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDHALMODEINFO) * max_modes);
+  dd_modes = X11DRV_Settings_SetHandlers("XF86VidMode", 
+                                         X11DRV_XF86VM_GetCurrentMode, 
+                                         X11DRV_XF86VM_SetCurrentMode, 
+                                         nmodes, 1);
 
   /* convert modes to DDHALMODEINFO format */
   for (i=0; i<real_xf86vm_mode_count; i++)
   {
-      convert_modeinfo(real_xf86vm_modes[i], &dd_modes[dd_mode_count++], dwBpp);
+      convert_modeinfo(real_xf86vm_modes[i]);
   }
   /* add modes for different color depths */
-  for (j=0; j<3; j++)
-  {
-      if (depths[j] != dwBpp)
-      {
-          for (i=0; i < real_xf86vm_mode_count; i++)
-          {
-              convert_modeinfo(real_xf86vm_modes[i], &dd_modes[dd_mode_count++], depths[j]);
-          }
-      }
-  }
+  X11DRV_Settings_AddDepthModes();
+  dd_mode_count = X11DRV_Settings_GetModeCount();
 
   TRACE("Available DD modes: count=%d\n", dd_mode_count);
 
   /* store the current mode at the time we started */
   xf86vm_initial_mode = X11DRV_XF86VM_GetCurrentMode();
-
+  X11DRV_Settings_SetDefaultMode(xf86vm_initial_mode);
+  
   TRACE("Enabling XVidMode\n");
 }
 
@@ -185,57 +219,6 @@
   if (real_xf86vm_modes) TSXFree(real_xf86vm_modes);
 }
 
-int X11DRV_XF86VM_GetCurrentMode(void)
-{
-  XF86VidModeModeLine line;
-  int dotclock, i;
-  DDHALMODEINFO cmode;
-  DWORD dwBpp = screen_depth;
-  if (dwBpp == 24) dwBpp = 32;
-
-  if (!dd_modes) return 0; /* no XVidMode */
-
-  TRACE("Querying XVidMode current mode\n");
-  wine_tsx11_lock();
-  XF86VidModeGetModeLine(gdi_display, DefaultScreen(gdi_display), &dotclock, &line);
-  wine_tsx11_unlock();
-  convert_modeline(dotclock, &line, &cmode, dwBpp);
-  for (i=0; i<dd_mode_count; i++)
-    if (memcmp(&dd_modes[i], &cmode, sizeof(cmode)) == 0) {
-      TRACE("mode=%d\n", i);
-      return i;
-    }
-  ERR("unknown mode, shouldn't happen\n");
-  return 0; /* return first mode */
-}
-
-void X11DRV_XF86VM_SetCurrentMode(int mode)
-{
-  if (!dd_modes) return; /* no XVidMode */
-
-  /* only set modes from the original color depth */
-  mode = mode % real_xf86vm_mode_count;
-
-  wine_tsx11_lock();
-  TRACE("Resizing X display to %dx%d\n", 
-        real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
-  XF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), real_xf86vm_modes[mode]);
-#if 0 /* FIXME */
-  SYSMETRICS_Set( SM_CXSCREEN, real_xf86vm_modes[mode]->hdisplay );
-  SYSMETRICS_Set( SM_CYSCREEN, real_xf86vm_modes[mode]->vdisplay );
-#else
-  FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n",
-        real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
-#endif
-#if 0 /* it is said that SetViewPort causes problems with some X servers */
-  XF86VidModeSetViewPort(gdi_display, DefaultScreen(gdi_display), 0, 0);
-#else
-  XWarpPointer(gdi_display, None, DefaultRootWindow(gdi_display), 0, 0, 0, 0, 0, 0);
-#endif
-  XSync(gdi_display, False);
-  wine_tsx11_unlock();
-}
-
 void X11DRV_XF86VM_SetExclusiveMode(int lock)
 {
   if (!dd_modes) return; /* no XVidMode */
@@ -245,30 +228,6 @@
   wine_tsx11_unlock();
 }
 
-/* actual DirectDraw HAL stuff */
-
-static DWORD PASCAL X11DRV_XF86VM_SetMode(LPDDHAL_SETMODEDATA data)
-{
-  TRACE("Mode %ld requested by DDHAL\n", data->dwModeIndex);
-  X11DRV_XF86VM_SetCurrentMode(data->dwModeIndex);
-  X11DRV_DDHAL_SwitchMode(data->dwModeIndex, NULL, NULL);
-  data->ddRVal = DD_OK;
-  return DDHAL_DRIVER_HANDLED;
-}
-
-int X11DRV_XF86VM_CreateDriver(LPDDHALINFO info)
-{
-  if (!dd_mode_count) return 0; /* no XVidMode */
-
-  TRACE("Setting up XF86VM mode for DDRAW\n");
-  info->dwNumModes = dd_mode_count;
-  info->lpModeInfo = dd_modes;
-  X11DRV_DDHAL_SwitchMode(X11DRV_XF86VM_GetCurrentMode(), NULL, NULL);
-  info->lpDDCallbacks->SetMode = X11DRV_XF86VM_SetMode;
-  return TRUE;
-}
-
-
 /***** GAMMA CONTROL *****/
 /* (only available in XF86VidMode 2.x) */
 
@@ -452,244 +411,4 @@
 #else
   return FALSE;
 #endif
-}
-
-/* implementation of EnumDisplaySettings for XF86VM */
-BOOL X11DRV_XF86VM_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags)
-{
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    devmode->dmDisplayFlags = 0;
-    devmode->dmDisplayFrequency = 85;
-    devmode->dmSize = sizeof(DEVMODEW);
-    if (n == (DWORD)-1)
-    {
-        TRACE("mode %ld (current) -- getting current mode\n", n);
-        n = X11DRV_XF86VM_GetCurrentMode();
-    }
-    if (n == (DWORD)-2)
-    {
-        devmode->dmBitsPerPel = dwBpp;
-        devmode->dmPelsHeight = GetSystemMetrics(SM_CYSCREEN);
-        devmode->dmPelsWidth  = GetSystemMetrics(SM_CXSCREEN);
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
-        TRACE("mode %ld (registry) -- returning default %ldx%ldx%ldbpp\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
-        return TRUE;
-    }
-    if (n < dd_mode_count)
-    {
-        devmode->dmPelsWidth = dd_modes[n].dwWidth;
-        devmode->dmPelsHeight = dd_modes[n].dwHeight;
-        devmode->dmBitsPerPel = dd_modes[n].dwBPP;
-        devmode->dmDisplayFrequency = dd_modes[n].wRefreshRate;
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY);
-        TRACE("mode %ld -- %ldx%ldx%ldbpp %ld Hz\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel,
-              devmode->dmDisplayFrequency);
-        return TRUE;
-    }
-    TRACE("mode %ld -- not present\n", n);
-    return FALSE;
-}
-
-/* implementation of ChangeDisplaySettings for XF86VM */
-LONG X11DRV_XF86VM_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
-                                      HWND hwnd, DWORD flags, LPVOID lpvoid )
-{
-    DWORD i;
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    if (devmode==NULL)
-    {
-#ifdef HAVE_LIBXXF86VM
-        X11DRV_XF86VM_SetCurrentMode(xf86vm_initial_mode);
-#endif
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-
-#if 0 /* FIXME: only works if we update SYSMETRICS */
-    if ((!(devmode->dmFields & DM_BITSPERPEL) || devmode->dmBitsPerPel == dwBpp) &&
-        (!(devmode->dmFields & DM_PELSWIDTH)  || devmode->dmPelsWidth  == GetSystemMetrics(SM_CXSCREEN)) &&
-        (!(devmode->dmFields & DM_PELSHEIGHT) || devmode->dmPelsHeight == GetSystemMetrics(SM_CYSCREEN)))
-    {
-        /* we have a valid mode */
-        TRACE("Requested mode matches current mode -- no change!\n");
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-#endif
-
-#ifdef HAVE_LIBXXF86VM
-    for (i = 0; i < dd_mode_count; i++)
-    {
-        if (devmode->dmFields & DM_BITSPERPEL)
-        {
-            if (devmode->dmBitsPerPel != dd_modes[i].dwBPP)
-                continue;
-        }
-        if (devmode->dmFields & DM_PELSWIDTH)
-        {
-            if (devmode->dmPelsWidth != dd_modes[i].dwWidth)
-                continue;
-        }
-        if (devmode->dmFields & DM_PELSHEIGHT)
-        {
-            if (devmode->dmPelsHeight != dd_modes[i].dwHeight)
-                continue;
-        }
-        if (devmode->dmFields & DM_DISPLAYFREQUENCY)
-        {
-            if (devmode->dmDisplayFrequency != dd_modes[i].wRefreshRate)
-                continue;
-        }
-        /* we have a valid mode */
-        TRACE("Requested display settings match mode %ld\n", i);
-        X11DRV_XF86VM_SetCurrentMode(i);
-        if (dwBpp != dd_modes[i].dwBPP)
-        {
-            FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[i].dwBPP);
-        }
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-#endif
-
-    /* no valid modes found */
-    ERR("No matching mode found!\n");
-    return DISP_CHANGE_BADMODE;
-}
-
-/* implementation of EnumDisplaySettings for nores */
-BOOL X11DRV_nores_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags)
-{
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    devmode->dmDisplayFlags = 0;
-    devmode->dmDisplayFrequency = 85;
-    devmode->dmSize = sizeof(DEVMODEW);
-    if (n==0 || n == (DWORD)-1 || n == (DWORD)-2)
-    {
-        devmode->dmBitsPerPel = dwBpp;
-        devmode->dmPelsHeight = GetSystemMetrics(SM_CYSCREEN);
-        devmode->dmPelsWidth  = GetSystemMetrics(SM_CXSCREEN);
-        devmode->dmFields = (DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL);
-        TRACE("mode %ld -- returning default %ldx%ldx%ldbpp\n", n,
-              devmode->dmPelsWidth, devmode->dmPelsHeight, devmode->dmBitsPerPel);
-        return TRUE;
-    }
-    TRACE("mode %ld -- not present\n", n);
-    return FALSE;
-}
-
-/* implementation of ChangeDisplaySettings for nores */
-LONG X11DRV_nores_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
-                                            HWND hwnd, DWORD flags, LPVOID lpvoid )
-{
-    DWORD dwBpp = screen_depth;
-    if (dwBpp == 24) dwBpp = 32;
-    if (devmode==NULL)
-    {
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-
-    if ((!(devmode->dmFields & DM_BITSPERPEL) || devmode->dmBitsPerPel == dwBpp) &&
-        (!(devmode->dmFields & DM_PELSWIDTH)  || devmode->dmPelsWidth  == GetSystemMetrics(SM_CXSCREEN)) &&
-        (!(devmode->dmFields & DM_PELSHEIGHT) || devmode->dmPelsHeight == GetSystemMetrics(SM_CYSCREEN)))
-    {
-        /* we are in the desired mode */
-        TRACE("Requested mode matches current mode -- no change!\n");
-        return DISP_CHANGE_SUCCESSFUL;
-    }
-
-    /* no valid modes found */
-    ERR("No matching mode found!\n");
-    return DISP_CHANGE_BADMODE;
-}
-
-/***********************************************************************
- *		EnumDisplaySettingsExW  (X11DRV.@)
- *
- * FIXME: should move to somewhere appropriate
- */
-BOOL X11DRV_EnumDisplaySettingsExW( LPCWSTR name, DWORD n, LPDEVMODEW devmode, DWORD flags)
-{
-    if (dd_modes) 
-    {
-        /* XVidMode */
-        return X11DRV_XF86VM_EnumDisplaySettingsExW(name, n, devmode, flags);
-    }
-    else if (in_desktop_mode)
-    {
-        /* desktop */
-        return X11DRV_desktop_EnumDisplaySettingsExW(name, n, devmode, flags);
-    }
-    else
-    {
-        /* no resolution changing */
-        return X11DRV_nores_EnumDisplaySettingsExW(name, n, devmode, flags);
-    }
-}
-
-#define _X_FIELD(prefix, bits) if ((fields) & prefix##_##bits) {p+=sprintf(p, "%s%s", first ? "" : ",", #bits); first=FALSE;}
-static const char * _CDS_flags(DWORD fields)
-{
-    BOOL first = TRUE;
-    char buf[128];
-    char *p = buf;
-    _X_FIELD(CDS,UPDATEREGISTRY);_X_FIELD(CDS,TEST);_X_FIELD(CDS,FULLSCREEN);
-    _X_FIELD(CDS,GLOBAL);_X_FIELD(CDS,SET_PRIMARY);_X_FIELD(CDS,RESET);
-    _X_FIELD(CDS,SETRECT);_X_FIELD(CDS,NORESET);
-    *p = 0;
-    return wine_dbg_sprintf("%s", buf);
-}
-static const char * _DM_fields(DWORD fields)
-{
-    BOOL first = TRUE;
-    char buf[128];
-    char *p = buf;
-    _X_FIELD(DM,BITSPERPEL);_X_FIELD(DM,PELSWIDTH);_X_FIELD(DM,PELSHEIGHT);
-    _X_FIELD(DM,DISPLAYFLAGS);_X_FIELD(DM,DISPLAYFREQUENCY);_X_FIELD(DM,POSITION);
-    *p = 0;
-    return wine_dbg_sprintf("%s", buf);
-}
-#undef _X_FIELD
-
-/***********************************************************************
- *		ChangeDisplaySettingsExW  (X11DRV.@)
- *
- * FIXME: should move to somewhere appropriate
- */
-LONG X11DRV_ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode,
-                                      HWND hwnd, DWORD flags, LPVOID lpvoid )
-{
-    TRACE("(%s,%p,%p,0x%08lx,%p\n",debugstr_w(devname),devmode,hwnd,flags,lpvoid);
-    TRACE("flags=%s\n",_CDS_flags(flags));
-    if (devmode)
-    {
-        TRACE("DM_fields=%s\n",_DM_fields(devmode->dmFields));
-        TRACE("width=%ld height=%ld bpp=%ld freq=%ld\n",
-              devmode->dmPelsWidth,devmode->dmPelsHeight,
-              devmode->dmBitsPerPel,devmode->dmDisplayFrequency);
-    }
-    else
-    {
-        TRACE("Return to original display mode\n");
-    }
-    if (dd_modes) 
-    {
-        /* XVidMode */
-        return X11DRV_XF86VM_ChangeDisplaySettingsExW( devname, devmode,
-                                                       hwnd, flags, lpvoid );
-    }
-    else if (in_desktop_mode)
-    {
-        /* no XVidMode */
-        return X11DRV_desktop_ChangeDisplaySettingsExW( devname, devmode,
-                                                        hwnd, flags, lpvoid );
-    }
-    else
-    {
-        /* no resolution changing */
-        return X11DRV_nores_ChangeDisplaySettingsExW( devname, devmode,
-                                                      hwnd, flags, lpvoid );
-    }
 }
Index: dlls/x11drv/xvidmode.h
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/xvidmode.h,v
retrieving revision 1.6
diff -u -r1.6 xvidmode.h
--- dlls/x11drv/xvidmode.h	5 Sep 2003 23:08:26 -0000	1.6
+++ dlls/x11drv/xvidmode.h	11 Oct 2003 17:55:32 -0000
@@ -31,15 +31,9 @@
 #include "wingdi.h"
 #include "ddrawi.h"
 
-extern LPDDHALMODEINFO xf86vm_modes;
-extern unsigned xf86vm_mode_count;
-
 void X11DRV_XF86VM_Init(void);
 void X11DRV_XF86VM_Cleanup(void);
-int X11DRV_XF86VM_GetCurrentMode(void);
-void X11DRV_XF86VM_SetCurrentMode(int mode);
 void X11DRV_XF86VM_SetExclusiveMode(int lock);
-int X11DRV_XF86VM_CreateDriver(LPDDHALINFO info);
 
 BOOL X11DRV_XF86VM_GetGammaRamp(LPDDGAMMARAMP ramp);
 BOOL X11DRV_XF86VM_SetGammaRamp(LPDDGAMMARAMP ramp);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux