Commit 0f03f264 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Add a helper function to return the primary monitor rectangle.

parent 9f1f29cc
......@@ -47,7 +47,11 @@ static const unsigned int heights[] = {200, 300, 384, 480, 600, 768, 864, 1024
/* create the mode structures */
static void make_modes(void)
{
RECT primary_rect = get_primary_monitor_rect();
unsigned int i;
unsigned int screen_width = primary_rect.right - primary_rect.left;
unsigned int screen_height = primary_rect.bottom - primary_rect.top;
/* original specified desktop size */
X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60);
for (i=0; i<NUM_DESKTOP_MODES; i++)
......@@ -73,10 +77,12 @@ static int X11DRV_desktop_GetCurrentMode(void)
{
unsigned int i;
DWORD dwBpp = screen_bpp;
RECT primary_rect = get_primary_monitor_rect();
for (i=0; i<dd_mode_count; i++)
{
if ( (screen_width == dd_modes[i].width) &&
(screen_height == dd_modes[i].height) &&
if ( (primary_rect.right - primary_rect.left == dd_modes[i].width) &&
(primary_rect.bottom - primary_rect.top == dd_modes[i].height) &&
(dwBpp == dd_modes[i].bpp))
return i;
}
......@@ -108,10 +114,12 @@ static LONG X11DRV_desktop_SetCurrentMode(int mode)
*/
void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height )
{
RECT primary_rect = get_primary_monitor_rect();
root_window = win;
managed_mode = 0; /* no managed windows in desktop mode */
max_width = screen_width;
max_height = screen_height;
max_width = primary_rect.right - primary_rect.left;
max_height = primary_rect.bottom - primary_rect.top;
xinerama_init( width, height );
/* initialize the available resolutions */
......@@ -135,6 +143,7 @@ BOOL CDECL X11DRV_create_desktop( UINT width, UINT height )
XSetWindowAttributes win_attr;
Window win;
Display *display = thread_init_display();
RECT rect;
TRACE( "%u x %u\n", width, height );
......@@ -154,7 +163,8 @@ BOOL CDECL X11DRV_create_desktop( UINT width, UINT height )
CWEventMask | CWCursor | CWColormap, &win_attr );
if (!win) return FALSE;
if (width == screen_width && height == screen_height)
SetRect( &rect, 0, 0, width, height );
if (is_window_rect_fullscreen( &rect ))
{
TRACE("setting desktop to fullscreen\n");
XChangeProperty( display, win, x11drv_atom(_NET_WM_STATE), XA_ATOM, 32,
......@@ -202,7 +212,9 @@ static BOOL CALLBACK update_windows_on_desktop_resize( HWND hwnd, LPARAM lparam
BOOL is_desktop_fullscreen(void)
{
return screen_width == max_width && screen_height == max_height;
RECT primary_rect = get_primary_monitor_rect();
return (primary_rect.right - primary_rect.left == max_width &&
primary_rect.bottom - primary_rect.top == max_height);
}
static void update_desktop_fullscreen( unsigned int width, unsigned int height)
......@@ -246,7 +258,7 @@ void X11DRV_resize_desktop( unsigned int width, unsigned int height )
HWND hwnd = GetDesktopWindow();
struct desktop_resize_data resize_data;
SetRect( &resize_data.old_screen_rect, 0, 0, screen_width, screen_height );
resize_data.old_screen_rect = get_primary_monitor_rect();
resize_data.old_virtual_rect = get_virtual_screen_rect();
xinerama_init( width, height );
......
......@@ -36,8 +36,6 @@ Display *gdi_display; /* display to use for all GDI functions */
/* a few dynamic device caps */
static int log_pixels_x; /* pixels per logical inch in x direction */
static int log_pixels_y; /* pixels per logical inch in y direction */
static int horz_size; /* horz. size of screen in millimeters */
static int vert_size; /* vert. size of screen in millimeters */
static int palette_size;
static Pixmap stock_bitmap_pixmap; /* phys bitmap for the default stock bitmap */
......@@ -94,8 +92,6 @@ static BOOL WINAPI device_init( INIT_ONCE *once, void *param, void **context )
/* Initialize device caps */
log_pixels_x = log_pixels_y = get_dpi();
horz_size = MulDiv( screen_width, 254, log_pixels_x * 10 );
vert_size = MulDiv( screen_height, 254, log_pixels_y * 10 );
return TRUE;
}
......@@ -204,13 +200,25 @@ static INT X11DRV_GetDeviceCaps( PHYSDEV dev, INT cap )
case TECHNOLOGY:
return DT_RASDISPLAY;
case HORZSIZE:
return horz_size;
{
RECT primary_rect = get_primary_monitor_rect();
return MulDiv( primary_rect.right - primary_rect.left, 254, log_pixels_x * 10 );
}
case VERTSIZE:
return vert_size;
{
RECT primary_rect = get_primary_monitor_rect();
return MulDiv( primary_rect.bottom - primary_rect.top, 254, log_pixels_y * 10 );
}
case HORZRES:
return screen_width;
{
RECT primary_rect = get_primary_monitor_rect();
return primary_rect.right - primary_rect.left;
}
case VERTRES:
return screen_height;
{
RECT primary_rect = get_primary_monitor_rect();
return primary_rect.bottom - primary_rect.top;
}
case DESKTOPHORZRES:
{
RECT virtual_rect = get_virtual_screen_rect();
......
......@@ -509,7 +509,7 @@ BOOL clip_fullscreen_window( HWND hwnd, BOOL reset )
if (!(thread_data = x11drv_thread_data())) return FALSE;
if (GetTickCount() - thread_data->clip_reset < 1000) return FALSE;
if (!reset && clipping_cursor && thread_data->clip_hwnd) return FALSE; /* already clipping */
SetRect( &rect, 0, 0, screen_width, screen_height );
rect = get_primary_monitor_rect();
if (!grab_fullscreen)
{
RECT virtual_rect = get_virtual_screen_rect();
......
......@@ -146,11 +146,12 @@ static LONG X11DRV_nores_SetCurrentMode(int mode)
/* default handler only gets the current X desktop resolution */
void X11DRV_Settings_Init(void)
{
RECT primary = get_primary_monitor_rect();
X11DRV_Settings_SetHandlers("NoRes",
X11DRV_nores_GetCurrentMode,
X11DRV_nores_SetCurrentMode,
1, 0);
X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60);
X11DRV_Settings_AddOneMode( primary.right - primary.left, primary.bottom - primary.top, 0, 60);
}
static BOOL get_display_device_reg_key(char *key, unsigned len)
......
......@@ -364,8 +364,6 @@ extern Colormap default_colormap DECLSPEC_HIDDEN;
extern XPixmapFormatValues **pixmap_formats DECLSPEC_HIDDEN;
extern Window root_window DECLSPEC_HIDDEN;
extern int clipping_cursor DECLSPEC_HIDDEN;
extern unsigned int screen_width DECLSPEC_HIDDEN;
extern unsigned int screen_height DECLSPEC_HIDDEN;
extern unsigned int screen_bpp DECLSPEC_HIDDEN;
extern int use_xkb DECLSPEC_HIDDEN;
extern int usexrandr DECLSPEC_HIDDEN;
......@@ -628,6 +626,7 @@ extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect )
extern POINT virtual_screen_to_root( INT x, INT y ) DECLSPEC_HIDDEN;
extern POINT root_to_virtual_screen( INT x, INT y ) DECLSPEC_HIDDEN;
extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
extern RECT get_primary_monitor_rect(void) DECLSPEC_HIDDEN;
extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
struct x11drv_mode_info
......@@ -675,8 +674,9 @@ static inline BOOL is_window_rect_mapped( const RECT *rect )
static inline BOOL is_window_rect_fullscreen( const RECT *rect )
{
return (rect->left <= 0 && rect->right >= screen_width &&
rect->top <= 0 && rect->bottom >= screen_height);
RECT primary_rect = get_primary_monitor_rect();
return (rect->left <= primary_rect.left && rect->right >= primary_rect.right &&
rect->top <= primary_rect.top && rect->bottom >= primary_rect.bottom);
}
#endif /* __WINE_X11DRV_H */
......@@ -60,8 +60,6 @@ XVisualInfo default_visual = { 0 };
XVisualInfo argb_visual = { 0 };
Colormap default_colormap = None;
XPixmapFormatValues **pixmap_formats;
unsigned int screen_width;
unsigned int screen_height;
unsigned int screen_bpp;
Window root_window;
int usexvidmode = 1;
......
......@@ -180,6 +180,11 @@ RECT get_virtual_screen_rect(void)
return virtual_screen_rect;
}
RECT get_primary_monitor_rect(void)
{
return get_primary()->rcMonitor;
}
void xinerama_init( unsigned int width, unsigned int height )
{
MONITORINFOEXW *primary;
......@@ -213,10 +218,8 @@ void xinerama_init( unsigned int width, unsigned int height )
(monitors[i].dwFlags & MONITORINFOF_PRIMARY) ? " (primary)" : "" );
}
screen_width = primary->rcMonitor.right - primary->rcMonitor.left;
screen_height = primary->rcMonitor.bottom - primary->rcMonitor.top;
TRACE( "virtual size: %s primary size: %dx%d\n",
wine_dbgstr_rect(&virtual_screen_rect), screen_width, screen_height );
TRACE( "virtual size: %s primary: %s\n",
wine_dbgstr_rect(&virtual_screen_rect), wine_dbgstr_rect(&primary->rcMonitor) );
}
......
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