Commit bab639e7 authored by Alex Pasadyn's avatar Alex Pasadyn Committed by Alexandre Julliard

- Added support for XRandR extension.

- Added new debugging channels for resolution changing. - Streamlined resolution changing and removed duplicated code.
parent c3c0c56c
...@@ -29,11 +29,13 @@ C_SRCS = \ ...@@ -29,11 +29,13 @@ C_SRCS = \
keyboard.c \ keyboard.c \
mouse.c \ mouse.c \
scroll.c \ scroll.c \
settings.c \
ts_xlib.c \ ts_xlib.c \
window.c \ window.c \
winpos.c \ winpos.c \
x11ddraw.c \ x11ddraw.c \
x11drv_main.c \ x11drv_main.c \
xrandr.c \
xrender.c \ xrender.c \
xvidmode.c xvidmode.c
......
...@@ -115,43 +115,22 @@ void X11DRV_create_desktop_thread(void) ...@@ -115,43 +115,22 @@ void X11DRV_create_desktop_thread(void)
/* data for resolution changing */ /* data for resolution changing */
static LPDDHALMODEINFO dd_modes; static LPDDHALMODEINFO dd_modes;
static int nmodes; static unsigned int dd_mode_count;
static unsigned int max_width; static unsigned int max_width;
static unsigned int max_height; static unsigned int max_height;
static const unsigned int widths[] = {320, 512, 640, 800, 1024, 1152, 1280, 1600}; 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 heights[] = {200, 384, 480, 600, 768, 864, 1024, 1200};
static const unsigned int depths[] = {8, 16, 32}; #define NUM_DESKTOP_MODES (8)
/* 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);
}
/* create the mode structures */ /* create the mode structures */
static void make_modes(void) static void make_modes(void)
{ {
int i,j; int i;
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);
/* original specified desktop size */ /* original specified desktop size */
make_one_mode(&dd_modes[nmodes++], screen_width, screen_height, dwBpp); X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 0);
for (i=0; i<8; i++) for (i=0; i<NUM_DESKTOP_MODES; i++)
{ {
if ( (widths[i] <= max_width) && (heights[i] <= max_height) ) if ( (widths[i] <= max_width) && (heights[i] <= max_height) )
{ {
...@@ -159,25 +138,14 @@ static void make_modes(void) ...@@ -159,25 +138,14 @@ static void make_modes(void)
( (widths[i] != screen_width) || (heights[i] != screen_height) ) ) ( (widths[i] != screen_width) || (heights[i] != screen_height) ) )
{ {
/* only add them if they are smaller than the root window and unique */ /* 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)) if ((max_width != screen_width) && (max_height != screen_height))
{ {
/* root window size (if different from desktop window) */ /* root window size (if different from desktop window) */
make_one_mode(&dd_modes[nmodes++], max_width, max_height, dwBpp); X11DRV_Settings_AddOneMode(max_width, max_height, 0, 0);
}
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]);
}
}
} }
} }
...@@ -224,6 +192,33 @@ int X11DRV_resize_desktop( unsigned int width, unsigned int height ) ...@@ -224,6 +192,33 @@ int X11DRV_resize_desktop( unsigned int width, unsigned int height )
return 1; 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 * X11DRV_create_desktop
...@@ -297,145 +292,13 @@ Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry ) ...@@ -297,145 +292,13 @@ Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
XFlush( display ); XFlush( display );
wine_tsx11_unlock(); wine_tsx11_unlock();
/* initialize the available resolutions */ /* initialize the available resolutions */
dd_modes = X11DRV_Settings_SetHandlers("desktop",
X11DRV_desktop_GetCurrentMode,
X11DRV_desktop_SetCurrentMode,
NUM_DESKTOP_MODES+2, 1);
make_modes(); make_modes();
X11DRV_Settings_AddDepthModes();
dd_mode_count = X11DRV_Settings_GetModeCount();
X11DRV_Settings_SetDefaultMode(0);
return win; 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;
}
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "x11drv.h" #include "x11drv.h"
#include "x11ddraw.h" #include "x11ddraw.h"
#include "xvidmode.h" #include "xvidmode.h"
#include "xrandr.h"
#include "dga2.h" #include "dga2.h"
#include "windef.h" #include "windef.h"
...@@ -382,12 +383,7 @@ INT X11DRV_DCICommand(INT cbInput, const DCICMD *lpCmd, LPVOID lpOutData) ...@@ -382,12 +383,7 @@ INT X11DRV_DCICommand(INT cbInput, const DCICMD *lpCmd, LPVOID lpOutData)
if (!X11DRV_XF86DGA2_CreateDriver(&hal_info)) if (!X11DRV_XF86DGA2_CreateDriver(&hal_info))
#endif #endif
{ {
#ifdef HAVE_LIBXXF86VM X11DRV_Settings_CreateDriver(&hal_info);
if (!X11DRV_XF86VM_CreateDriver(&hal_info))
#endif
{
X11DRV_desktop_CreateDriver(&hal_info);
}
} }
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
/*X11DRV_GLX_CreateDriver(&hal_info);*/ /*X11DRV_GLX_CreateDriver(&hal_info);*/
......
...@@ -491,13 +491,22 @@ extern void X11DRV_window_to_X_rect( WND *win, RECT *rect ); ...@@ -491,13 +491,22 @@ extern void X11DRV_window_to_X_rect( WND *win, RECT *rect );
extern void X11DRV_X_to_window_rect( WND *win, RECT *rect ); extern void X11DRV_X_to_window_rect( WND *win, RECT *rect );
extern void X11DRV_create_desktop_thread(void); extern void X11DRV_create_desktop_thread(void);
extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry ); 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 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_whole_window_position( Display *display, WND *win, int zorder );
extern int X11DRV_sync_client_window_position( Display *display, WND *win ); extern int X11DRV_sync_client_window_position( Display *display, WND *win );
extern void X11DRV_set_wm_hints( 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 */ #endif /* __WINE_X11DRV_H */
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "win.h" #include "win.h"
#include "x11drv.h" #include "x11drv.h"
#include "xvidmode.h" #include "xvidmode.h"
#include "xrandr.h"
#include "dga2.h" #include "dga2.h"
#include "wine/server.h" #include "wine/server.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -70,7 +71,7 @@ unsigned int screen_height; ...@@ -70,7 +71,7 @@ unsigned int screen_height;
unsigned int screen_depth; unsigned int screen_depth;
Window root_window; Window root_window;
DWORD desktop_tid = 0; DWORD desktop_tid = 0;
int dxgrab, usedga, usexvidmode; int dxgrab, usedga, usexvidmode, usexrandr;
int use_xkb = 1; int use_xkb = 1;
int use_take_focus = 1; int use_take_focus = 1;
int managed_mode = 1; int managed_mode = 1;
...@@ -261,6 +262,9 @@ static void setup_options(void) ...@@ -261,6 +262,9 @@ static void setup_options(void)
if (!get_config_key( hkey, appkey, "UseXVidMode", buffer, sizeof(buffer) )) if (!get_config_key( hkey, appkey, "UseXVidMode", buffer, sizeof(buffer) ))
usexvidmode = IS_OPTION_TRUE( buffer[0] ); 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) )) if (!get_config_key( hkey, appkey, "UseTakeFocus", buffer, sizeof(buffer) ))
use_take_focus = IS_OPTION_TRUE( buffer[0] ); use_take_focus = IS_OPTION_TRUE( buffer[0] );
...@@ -361,6 +365,8 @@ static void process_attach(void) ...@@ -361,6 +365,8 @@ static void process_attach(void)
screen_width = WidthOfScreen( screen ); screen_width = WidthOfScreen( screen );
screen_height = HeightOfScreen( screen ); screen_height = HeightOfScreen( screen );
X11DRV_Settings_Init();
if (desktop_geometry) if (desktop_geometry)
root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry ); root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
...@@ -382,6 +388,10 @@ static void process_attach(void) ...@@ -382,6 +388,10 @@ static void process_attach(void)
/* initialize XVidMode */ /* initialize XVidMode */
X11DRV_XF86VM_Init(); X11DRV_XF86VM_Init();
#endif #endif
#ifdef HAVE_LIBXRANDR
/* initialize XRandR */
X11DRV_XRandR_Init();
#endif
#ifdef HAVE_LIBXXF86DGA2 #ifdef HAVE_LIBXXF86DGA2
/* initialize DGA2 */ /* initialize DGA2 */
X11DRV_XF86DGA2_Init(); X11DRV_XF86DGA2_Init();
......
/*
* Wine X11drv Xrandr interface
*
* Copyright 2003 Alexander James Pasadyn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#ifdef HAVE_LIBXRANDR
#include "ts_xlib.h"
#include <X11/extensions/Xrandr.h>
#include "x11drv.h"
#include "x11ddraw.h"
#include "xrandr.h"
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "ddrawi.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(xrandr);
extern int usexrandr;
static int xrandr_event, xrandr_error, xrandr_major, xrandr_minor;
static LPDDHALMODEINFO dd_modes;
static unsigned int dd_mode_count;
static XRRScreenSize *real_xrandr_sizes;
static short **real_xrandr_rates;
static unsigned int real_xrandr_sizes_count;
static int *real_xrandr_rates_count;
static unsigned int real_xrandr_modes_count;
static int XRandRErrorHandler(Display *dpy, XErrorEvent *event, void *arg)
{
return 1;
}
static Bool in_desktop_mode;
static const unsigned int depths[] = {8, 16, 32};
/* create the mode structures */
static void make_modes(void)
{
int i, j;
for (i=0; i<real_xrandr_sizes_count; i++)
{
if (real_xrandr_rates_count[i])
{
for (j=0; j < real_xrandr_rates_count[i]; j++)
{
X11DRV_Settings_AddOneMode(real_xrandr_sizes[i].width,
real_xrandr_sizes[i].height,
0, real_xrandr_rates[i][j]);
}
}
else
{
X11DRV_Settings_AddOneMode(real_xrandr_sizes[i].width,
real_xrandr_sizes[i].height,
0, 0);
}
}
}
static int X11DRV_XRandR_GetCurrentMode(void)
{
SizeID size;
Rotation rot;
Window root;
XRRScreenConfiguration *sc;
short rate;
int i;
int res = -1;
wine_tsx11_lock();
root = RootWindow (gdi_display, DefaultScreen(gdi_display));
sc = XRRGetScreenInfo (gdi_display, root);
size = XRRConfigCurrentConfiguration (sc, &rot);
rate = XRRConfigCurrentRate (sc);
for (i = 0; i < real_xrandr_modes_count; i++)
{
if ( (dd_modes[i].dwWidth == real_xrandr_sizes[size].width ) &&
(dd_modes[i].dwHeight == real_xrandr_sizes[size].height) &&
(dd_modes[i].wRefreshRate == rate ) )
{
res = i;
}
}
XRRFreeScreenConfigInfo(sc);
wine_tsx11_unlock();
if (res == -1)
{
ERR("In unknown mode, returning default\n");
res = 0;
}
return res;
}
static void X11DRV_XRandR_SetCurrentMode(int mode)
{
SizeID size;
Rotation rot;
Window root;
XRRScreenConfiguration *sc;
Status stat = RRSetConfigSuccess;
short rate;
int i, j;
DWORD dwBpp = screen_depth;
if (dwBpp == 24) dwBpp = 32;
wine_tsx11_lock();
root = RootWindow (gdi_display, DefaultScreen(gdi_display));
sc = XRRGetScreenInfo (gdi_display, root);
size = XRRConfigCurrentConfiguration (sc, &rot);
if (dwBpp != dd_modes[mode].dwBPP)
{
FIXME("Cannot change screen BPP from %ld to %ld\n", dwBpp, dd_modes[mode].dwBPP);
}
mode = mode%real_xrandr_modes_count;
for (i = 0; i < real_xrandr_sizes_count; i++)
{
if ( (dd_modes[mode].dwWidth == real_xrandr_sizes[i].width ) &&
(dd_modes[mode].dwHeight == real_xrandr_sizes[i].height) )
{
size = i;
if (real_xrandr_rates_count[i])
{
for (j=0; j < real_xrandr_rates_count[i]; j++)
{
if (dd_modes[mode].wRefreshRate == real_xrandr_rates[i][j])
{
rate = real_xrandr_rates[i][j];
TRACE("Resizing X display to %ldx%ld @%d Hz\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight, rate);
stat = XRRSetScreenConfigAndRate (gdi_display, sc, root,
size, rot, rate, CurrentTime);
FIXME("Need to update SYSMETRICS after resizing display (now %ldx%ld)\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
}
}
}
else
{
TRACE("Resizing X display to %ldx%ld\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
stat = XRRSetScreenConfig (gdi_display, sc, root,
size, rot, CurrentTime);
FIXME("Need to update SYSMETRICS after resizing display (now %ldx%ld)\n",
dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
}
}
}
if (stat != RRSetConfigSuccess)
{
ERR("Resolution change not successful -- perhaps display has chaned?");
}
XRRFreeScreenConfigInfo(sc);
wine_tsx11_unlock();
}
void X11DRV_XRandR_Init(void)
{
Bool ok;
int nmodes = 0;
int i;
in_desktop_mode = (root_window != DefaultRootWindow(gdi_display));
if (xrandr_major) return; /* already initialized? */
if (!usexrandr) return; /* disabled in config */
if (in_desktop_mode) return; /* not compatible with desktop mode */
/* see if Xrandr is available */
wine_tsx11_lock();
ok = XRRQueryExtension(gdi_display, &xrandr_event, &xrandr_error);
if (ok)
{
X11DRV_expect_error(gdi_display, XRandRErrorHandler, NULL);
ok = XRRQueryVersion(gdi_display, &xrandr_major, &xrandr_minor);
if (X11DRV_check_error()) ok = FALSE;
}
if (ok)
{
TRACE("Found XRandR - major: %d, minor: %d\n", xrandr_major, xrandr_minor);
/* retrieve modes */
real_xrandr_sizes = XRRSizes(gdi_display, DefaultScreen(gdi_display), &real_xrandr_sizes_count);
ok = (real_xrandr_sizes_count>0);
}
if (ok)
{
real_xrandr_rates = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(short *) * real_xrandr_sizes_count);
real_xrandr_rates_count = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(int) * real_xrandr_sizes_count);
for (i=0; i < real_xrandr_sizes_count; i++)
{
real_xrandr_rates[i] = XRRRates (gdi_display, DefaultScreen(gdi_display), i, &(real_xrandr_rates_count[i]));
if (real_xrandr_rates_count[i])
{
nmodes += real_xrandr_rates_count[i];
}
else
{
nmodes++;
}
}
}
wine_tsx11_unlock();
if (!ok) return;
real_xrandr_modes_count = nmodes;
TRACE("XRandR modes: count=%d\n", nmodes);
dd_modes = X11DRV_Settings_SetHandlers("XRandR",
X11DRV_XRandR_GetCurrentMode,
X11DRV_XRandR_SetCurrentMode,
nmodes, 1);
make_modes();
X11DRV_Settings_AddDepthModes();
dd_mode_count = X11DRV_Settings_GetModeCount();
X11DRV_Settings_SetDefaultMode(0);
TRACE("Available DD modes: count=%d\n", dd_mode_count);
TRACE("Enabling XRandR\n");
}
void X11DRV_XRandR_Cleanup(void)
{
if (real_xrandr_rates)
{
HeapFree(GetProcessHeap(), 0, real_xrandr_rates);
real_xrandr_rates = NULL;
}
if (real_xrandr_rates_count)
{
HeapFree(GetProcessHeap(), 0, real_xrandr_rates_count);
real_xrandr_rates_count = NULL;
}
}
#endif /* HAVE_LIBXRANDR */
/*
* Wine X11drv Xrandr interface
*
* Copyright 2003 Alexander James Pasadyn
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __WINE_XRANDR_H
#define __WINE_XRANDR_H
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#ifdef HAVE_LIBXRANDR
void X11DRV_XRandR_Init(void);
void X11DRV_XRandR_Cleanup(void);
#endif /* HAVE_LIBXRANDR */
#endif /* __WINE_XRANDR_H */
...@@ -31,15 +31,9 @@ ...@@ -31,15 +31,9 @@
#include "wingdi.h" #include "wingdi.h"
#include "ddrawi.h" #include "ddrawi.h"
extern LPDDHALMODEINFO xf86vm_modes;
extern unsigned xf86vm_mode_count;
void X11DRV_XF86VM_Init(void); void X11DRV_XF86VM_Init(void);
void X11DRV_XF86VM_Cleanup(void); void X11DRV_XF86VM_Cleanup(void);
int X11DRV_XF86VM_GetCurrentMode(void);
void X11DRV_XF86VM_SetCurrentMode(int mode);
void X11DRV_XF86VM_SetExclusiveMode(int lock); void X11DRV_XF86VM_SetExclusiveMode(int lock);
int X11DRV_XF86VM_CreateDriver(LPDDHALINFO info);
BOOL X11DRV_XF86VM_GetGammaRamp(LPDDGAMMARAMP ramp); BOOL X11DRV_XF86VM_GetGammaRamp(LPDDGAMMARAMP ramp);
BOOL X11DRV_XF86VM_SetGammaRamp(LPDDGAMMARAMP ramp); BOOL X11DRV_XF86VM_SetGammaRamp(LPDDGAMMARAMP ramp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment