Update wine to 1.2.
[sugaredwine.git] / patches / 0002-hack-to-make-SPI_SETWORKAREA-work-in-virtual-desktop.patch
blobe054051cf10a7e6170358e1a81c47ec4ac8093a1
1 From beeba9490024cee080f8dd285ad890e47613a13b Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Wed, 24 Sep 2008 11:40:57 -0500
4 Subject: [PATCH] hack to make SPI_SETWORKAREA work in virtual desktop mode
6 ---
7 dlls/user32/driver.c | 12 +++++++++++
8 dlls/user32/sysparams.c | 23 +++++++--------------
9 dlls/user32/user_private.h | 1 +
10 dlls/winex11.drv/desktop.c | 2 +-
11 dlls/winex11.drv/event.c | 5 ++++
12 dlls/winex11.drv/winex11.drv.spec | 1 +
13 dlls/winex11.drv/x11drv.h | 1 +
14 dlls/winex11.drv/x11drv_main.c | 7 ++++++
15 dlls/winex11.drv/xinerama.c | 39 +++++++++++++++++++++++++++++++++++++
16 9 files changed, 75 insertions(+), 16 deletions(-)
18 diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
19 index f2f9892..d5a8a05 100644
20 --- a/dlls/user32/driver.c
21 +++ b/dlls/user32/driver.c
22 @@ -106,6 +106,7 @@ static const USER_DRIVER *load_driver(void)
23 GET_USER_FUNC(EnumDisplayMonitors);
24 GET_USER_FUNC(EnumDisplaySettingsEx);
25 GET_USER_FUNC(GetMonitorInfo);
26 + GET_USER_FUNC(SetWorkArea);
27 GET_USER_FUNC(CreateDesktopWindow);
28 GET_USER_FUNC(CreateWindow);
29 GET_USER_FUNC(DestroyWindow);
30 @@ -322,6 +323,10 @@ static BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
31 return FALSE;
34 +static void CDECL nulldrv_SetWorkArea( RECT *rc )
38 static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
40 return TRUE;
41 @@ -478,6 +483,7 @@ static USER_DRIVER null_driver =
42 nulldrv_EnumDisplayMonitors,
43 nulldrv_EnumDisplaySettingsEx,
44 nulldrv_GetMonitorInfo,
45 + nulldrv_SetWorkArea,
46 /* windowing functions */
47 nulldrv_CreateDesktopWindow,
48 nulldrv_CreateWindow,
49 @@ -681,6 +687,11 @@ static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info
50 return load_driver()->pGetMonitorInfo( handle, info );
53 +static void CDECL loaderdrv_SetWorkArea( RECT *rc )
55 + load_driver()->pSetWorkArea( rc );
58 static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
60 return load_driver()->pCreateDesktopWindow( hwnd );
61 @@ -831,6 +842,7 @@ static USER_DRIVER lazy_load_driver =
62 loaderdrv_EnumDisplayMonitors,
63 loaderdrv_EnumDisplaySettingsEx,
64 loaderdrv_GetMonitorInfo,
65 + loaderdrv_SetWorkArea,
66 /* windowing functions */
67 loaderdrv_CreateDesktopWindow,
68 loaderdrv_CreateWindow,
69 diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
70 index 3d4075f..80375be 100644
71 --- a/dlls/user32/sysparams.c
72 +++ b/dlls/user32/sysparams.c
73 @@ -305,7 +305,6 @@ static UINT double_click_width = 4;
74 static UINT double_click_height = 4;
75 static UINT double_click_time = 500;
76 static BOOL drag_full_windows = FALSE;
77 -static RECT work_area;
78 static BOOL keyboard_pref = TRUE;
79 static BOOL screen_reader = FALSE;
80 static UINT mouse_hover_width = 4;
81 @@ -1722,9 +1721,8 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
83 if (!pvParam) return FALSE;
85 - spi_idx = SPI_SETWORKAREA_IDX;
86 - CopyRect( &work_area, pvParam );
87 - spi_loaded[spi_idx] = TRUE;
88 + USER_Driver->pSetWorkArea( (RECT*)pvParam );
90 break;
93 @@ -1732,17 +1730,12 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
95 if (!pvParam) return FALSE;
97 - spi_idx = SPI_SETWORKAREA_IDX;
98 - if (!spi_loaded[spi_idx])
99 - {
100 - SetRect( &work_area, 0, 0,
101 - GetSystemMetrics( SM_CXSCREEN ),
102 - GetSystemMetrics( SM_CYSCREEN ) );
103 - EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area );
104 - spi_loaded[spi_idx] = TRUE;
106 - CopyRect( pvParam, &work_area );
107 - TRACE("work area %s\n", wine_dbgstr_rect( &work_area ));
108 + SetRect( (RECT *)pvParam, 0, 0,
109 + GetSystemMetrics( SM_CXSCREEN ),
110 + GetSystemMetrics( SM_CYSCREEN ) );
111 + EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)pvParam );
113 + TRACE("work area %s\n", wine_dbgstr_rect( (RECT *)pvParam ));
114 break;
117 diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
118 index 23b4269..2b084b0 100644
119 --- a/dlls/user32/user_private.h
120 +++ b/dlls/user32/user_private.h
121 @@ -91,6 +91,7 @@ typedef struct tagUSER_DRIVER {
122 BOOL (CDECL *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
123 BOOL (CDECL *pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
124 BOOL (CDECL *pGetMonitorInfo)(HMONITOR,MONITORINFO*);
125 + void (CDECL *pSetWorkArea)(RECT*);
126 /* windowing functions */
127 BOOL (CDECL *pCreateDesktopWindow)(HWND);
128 BOOL (CDECL *pCreateWindow)(HWND);
129 diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
130 index 4a36e46..3decc59 100644
131 --- a/dlls/winex11.drv/desktop.c
132 +++ b/dlls/winex11.drv/desktop.c
133 @@ -142,7 +142,7 @@ Window CDECL X11DRV_create_desktop( UINT width, UINT height )
134 wine_tsx11_lock();
136 /* Create window */
137 - win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | EnterWindowMask |
138 + win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | EnterWindowMask | PropertyChangeMask |
139 PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
140 win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
142 diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c
143 index 8fc955a..014eb5e 100644
144 --- a/dlls/winex11.drv/event.c
145 +++ b/dlls/winex11.drv/event.c
146 @@ -1011,6 +1011,11 @@ static void X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
147 XPropertyEvent *event = &xev->xproperty;
148 struct x11drv_win_data *data;
150 + if (event->atom == x11drv_atom(_NET_WORKAREA))
152 + refresh_workarea( event->display, event->window );
155 if (!hwnd) return;
156 if (!(data = X11DRV_get_win_data( hwnd ))) return;
158 diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
159 index ab61f54..db74c34 100644
160 --- a/dlls/winex11.drv/winex11.drv.spec
161 +++ b/dlls/winex11.drv/winex11.drv.spec
162 @@ -84,6 +84,7 @@
163 @ cdecl EnumDisplayMonitors(long ptr ptr long) X11DRV_EnumDisplayMonitors
164 @ cdecl EnumDisplaySettingsEx(ptr long ptr long) X11DRV_EnumDisplaySettingsEx
165 @ cdecl GetMonitorInfo(long ptr) X11DRV_GetMonitorInfo
166 +@ cdecl SetWorkArea(long ptr) X11DRV_SetWorkArea
167 @ cdecl AcquireClipboard(long) X11DRV_AcquireClipboard
168 @ cdecl CountClipboardFormats() X11DRV_CountClipboardFormats
169 @ cdecl CreateDesktopWindow(long) X11DRV_CreateDesktopWindow
170 diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
171 index 1cd610d..b7932fb 100644
172 --- a/dlls/winex11.drv/x11drv.h
173 +++ b/dlls/winex11.drv/x11drv.h
174 @@ -800,6 +800,7 @@ extern void X11DRV_expect_error( Display *display, x11drv_error_callback callbac
175 extern int X11DRV_check_error(void);
176 extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect );
177 extern void xinerama_init( unsigned int width, unsigned int height );
178 +extern void refresh_workarea( Display* display, Window window );
180 extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height );
181 extern void X11DRV_resize_desktop(unsigned int width, unsigned int height);
182 diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c
183 index b07061c..3bd17f9 100644
184 --- a/dlls/winex11.drv/x11drv_main.c
185 +++ b/dlls/winex11.drv/x11drv_main.c
186 @@ -663,6 +663,13 @@ struct x11drv_thread_data *x11drv_init_thread_data(void)
187 #endif
189 if (TRACE_ON(synchronous)) XSynchronize( data->display, True );
191 + if (root_window && root_window != DefaultRootWindow(gdi_display))
193 + XSelectInput( data->display, root_window, PropertyChangeMask );
194 + refresh_workarea( data->display, root_window );
197 wine_tsx11_unlock();
199 set_queue_display_fd( data->display );
200 diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c
201 index 2a66df5..ae26faf 100644
202 --- a/dlls/winex11.drv/xinerama.c
203 +++ b/dlls/winex11.drv/xinerama.c
204 @@ -200,6 +200,25 @@ void xinerama_init( unsigned int width, unsigned int height )
205 ClipCursor( NULL ); /* reset the cursor clip rectangle */
208 +void refresh_workarea( Display* display, Window window )
210 + Atom type;
211 + int format;
212 + CARD32 *work_area;
213 + unsigned long count, remaining;
215 + if (!XGetWindowProperty( display, window, x11drv_atom(_NET_WORKAREA), 0,
216 + ~0, False, XA_CARDINAL, &type, &format, &count,
217 + &remaining, (unsigned char **)&work_area ))
219 + if (type == XA_CARDINAL && format == 32 && count >= 4)
221 + SetRect( &default_monitor.rcWork, work_area[0], work_area[1],
222 + work_area[0] + work_area[2], work_area[1] + work_area[3] );
224 + XFree( work_area );
228 /***********************************************************************
229 * X11DRV_GetMonitorInfo (X11DRV.@)
230 @@ -260,3 +279,23 @@ BOOL CDECL X11DRV_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC pro
232 return TRUE;
235 +/***********************************************************************
236 + * X11DRV_SetWorkArea (X11DRV.@)
237 + */
238 +void CDECL X11DRV_SetWorkArea( RECT *rc )
240 + CARD32 work_area[4];
241 + Display *display = thread_init_display();
243 + work_area[0] = rc->left;
244 + work_area[1] = rc->top;
245 + work_area[2] = rc->right - rc->left;
246 + work_area[3] = rc->bottom - rc->top;
248 + /* this only works by coincidence, but I'm too lazy to do it properly, since
249 + this approach is wrong anyway */
250 + XChangeProperty( display, root_window, x11drv_atom(_NET_WORKAREA),
251 + XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&work_area, 4);
255 1.5.6.5