winex11: Directly use win32u for user functions in window.c.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-04-13 15:08:59 +02:00 committed by Alexandre Julliard
parent 523a6eba02
commit 55f4cf8c85
2 changed files with 124 additions and 100 deletions

View File

@ -92,9 +92,12 @@ XContext win_data_context = 0;
static Time last_user_time;
static Window user_time_window;
static const char foreign_window_prop[] = "__wine_x11_foreign_window";
static const char whole_window_prop[] = "__wine_x11_whole_window";
static const char clip_window_prop[] = "__wine_x11_clip_window";
static const WCHAR foreign_window_prop[] =
{'_','_','w','i','n','e','_','x','1','1','_','f','o','r','e','i','g','n','_','w','i','n','d','o','w',0};
static const WCHAR whole_window_prop[] =
{'_','_','w','i','n','e','_','x','1','1','_','w','h','o','l','e','_','w','i','n','d','o','w',0};
static const WCHAR clip_window_prop[] =
{'_','_','w','i','n','e','_','x','1','1','_','c','l','i','p','_','w','i','n','d','o','w',0};
static CRITICAL_SECTION win_data_section;
static CRITICAL_SECTION_DEBUG critsect_debug =
@ -231,11 +234,11 @@ static BOOL is_window_managed( HWND hwnd, UINT swp_flags, const RECT *window_rec
if (!managed_mode) return FALSE;
/* child windows are not managed */
style = GetWindowLongW( hwnd, GWL_STYLE );
style = NtUserGetWindowLongW( hwnd, GWL_STYLE );
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD) return FALSE;
/* activated windows are managed */
if (!(swp_flags & (SWP_NOACTIVATE|SWP_HIDEWINDOW))) return TRUE;
if (hwnd == GetActiveWindow()) return TRUE;
if (hwnd == get_active_window()) return TRUE;
/* windows with caption are managed */
if ((style & WS_CAPTION) == WS_CAPTION) return TRUE;
/* windows with thick frame are managed */
@ -248,15 +251,15 @@ static BOOL is_window_managed( HWND hwnd, UINT swp_flags, const RECT *window_rec
/* popup with sysmenu == caption are managed */
if (style & WS_SYSMENU) return TRUE;
/* full-screen popup windows are managed */
hmon = MonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY );
hmon = NtUserMonitorFromWindow( hwnd, MONITOR_DEFAULTTOPRIMARY );
mi.cbSize = sizeof( mi );
GetMonitorInfoW( hmon, &mi );
NtUserGetMonitorInfo( hmon, &mi );
if (window_rect->left <= mi.rcWork.left && window_rect->right >= mi.rcWork.right &&
window_rect->top <= mi.rcWork.top && window_rect->bottom >= mi.rcWork.bottom)
return TRUE;
}
/* application windows are managed */
ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
ex_style = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE );
if (ex_style & WS_EX_APPWINDOW) return TRUE;
/* windows that own popups are managed */
if (has_owned_popups( hwnd )) return TRUE;
@ -347,7 +350,7 @@ static int get_window_attributes( struct x11drv_win_data *data, XSetWindowAttrib
{
attr->override_redirect = !data->managed;
attr->colormap = data->whole_colormap ? data->whole_colormap : default_colormap;
attr->save_under = ((GetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
attr->save_under = ((NtUserGetClassLongW( data->hwnd, GCL_STYLE ) & CS_SAVEBITS) != 0);
attr->bit_gravity = NorthWestGravity;
attr->backing_store = NotUseful;
attr->border_pixel = 0;
@ -403,7 +406,7 @@ static void sync_window_region( struct x11drv_win_data *data, HRGN win_region )
if (hrgn == (HRGN)1) /* hack: win_region == 1 means retrieve region from server */
{
if (!(hrgn = NtGdiCreateRectRgn( 0, 0, 0, 0 ))) return;
if (GetWindowRgn( data->hwnd, hrgn ) == ERROR)
if (NtUserGetWindowRgnEx( data->hwnd, hrgn, 0 ) == ERROR)
{
NtGdiDeleteObjectApp( hrgn );
hrgn = 0;
@ -418,7 +421,8 @@ static void sync_window_region( struct x11drv_win_data *data, HRGN win_region )
{
RGNDATA *pRegionData;
if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) MirrorRgn( data->hwnd, hrgn );
if (NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
NtUserMirrorRgn( data->hwnd, hrgn );
if ((pRegionData = X11DRV_GetRegionData( hrgn, 0 )))
{
XShapeCombineRectangles( data->display, data->whole_window, ShapeBounding,
@ -633,21 +637,21 @@ static void fetch_icon_data( HWND hwnd, HICON icon_big, HICON icon_small )
if (!icon_big)
{
icon_big = (HICON)SendMessageW( hwnd, WM_GETICON, ICON_BIG, 0 );
if (!icon_big) icon_big = (HICON)GetClassLongPtrW( hwnd, GCLP_HICON );
icon_big = (HICON)send_message( hwnd, WM_GETICON, ICON_BIG, 0 );
if (!icon_big) icon_big = (HICON)NtUserGetClassLongPtrW( hwnd, GCLP_HICON );
if (!icon_big) icon_big = LoadIconW( 0, (LPWSTR)IDI_WINLOGO );
}
if (!icon_small)
{
icon_small = (HICON)SendMessageW( hwnd, WM_GETICON, ICON_SMALL, 0 );
if (!icon_small) icon_small = (HICON)GetClassLongPtrW( hwnd, GCLP_HICONSM );
icon_small = (HICON)send_message( hwnd, WM_GETICON, ICON_SMALL, 0 );
if (!icon_small) icon_small = (HICON)NtUserGetClassLongPtrW( hwnd, GCLP_HICONSM );
}
if (!GetIconInfo(icon_big, &ii)) return;
if (!NtUserGetIconInfo( icon_big, &ii, NULL, NULL, NULL, 0 )) return;
hDC = NtGdiCreateCompatibleDC(0);
bits = get_bitmap_argb( hDC, ii.hbmColor, ii.hbmMask, &size );
if (bits && GetIconInfo( icon_small, &ii_small ))
if (bits && NtUserGetIconInfo( icon_small, &ii_small, NULL, NULL, NULL, 0 ))
{
unsigned int size_small;
unsigned long *bits_small, *new;
@ -711,7 +715,7 @@ static void set_size_hints( struct x11drv_win_data *data, DWORD style )
/* don't update size hints if window is not in normal state */
if (!(style & (WS_MINIMIZE | WS_MAXIMIZE)))
{
if (data->hwnd != GetDesktopWindow()) /* don't force position of desktop */
if (data->hwnd != NtUserGetDesktopWindow()) /* don't force position of desktop */
{
size_hints->x = data->whole_rect.left;
size_hints->y = data->whole_rect.top;
@ -742,7 +746,7 @@ static void set_mwm_hints( struct x11drv_win_data *data, DWORD style, DWORD ex_s
{
MwmHints mwm_hints;
if (data->hwnd == GetDesktopWindow())
if (data->hwnd == NtUserGetDesktopWindow())
{
if (is_desktop_fullscreen()) mwm_hints.decorations = 0;
else mwm_hints.decorations = MWM_DECOR_TITLE | MWM_DECOR_BORDER | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE;
@ -783,14 +787,14 @@ static void set_mwm_hints( struct x11drv_win_data *data, DWORD style, DWORD ex_s
static void set_style_hints( struct x11drv_win_data *data, DWORD style, DWORD ex_style )
{
Window group_leader = data->whole_window;
HWND owner = GetWindow( data->hwnd, GW_OWNER );
HWND owner = NtUserGetWindowRelative( data->hwnd, GW_OWNER );
Window owner_win = 0;
XWMHints *wm_hints;
Atom window_type;
if (owner)
{
owner = GetAncestor( owner, GA_ROOT );
owner = NtUserGetAncestor( owner, GA_ROOT );
owner_win = X11DRV_get_whole_window( owner );
}
@ -893,13 +897,13 @@ static void make_owner_managed( HWND hwnd )
{
HWND owner;
if (!(owner = GetWindow( hwnd, GW_OWNER ))) return;
if (!(owner = NtUserGetWindowRelative( hwnd, GW_OWNER ))) return;
if (is_managed( owner )) return;
if (!is_managed( hwnd )) return;
SetWindowPos( owner, 0, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED );
NtUserSetWindowPos( owner, 0, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE |
SWP_NOREDRAW | SWP_DEFERERASE | SWP_NOSENDCHANGING | SWP_STATECHANGED );
}
@ -912,7 +916,7 @@ static void set_wm_hints( struct x11drv_win_data *data )
{
DWORD style, ex_style;
if (data->hwnd == GetDesktopWindow())
if (data->hwnd == NtUserGetDesktopWindow())
{
/* force some styles for the desktop to get the correct decorations */
style = WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
@ -920,8 +924,8 @@ static void set_wm_hints( struct x11drv_win_data *data )
}
else
{
style = GetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE );
}
set_size_hints( data, style );
@ -938,7 +942,7 @@ Window init_clip_window(void)
struct x11drv_thread_data *data = x11drv_init_thread_data();
if (!data->clip_window &&
(data->clip_window = (Window)GetPropA( GetDesktopWindow(), clip_window_prop )))
(data->clip_window = (Window)NtUserGetProp( NtUserGetDesktopWindow(), clip_window_prop )))
{
XSelectInput( data->display, data->clip_window, StructureNotifyMask );
}
@ -981,7 +985,7 @@ void update_net_wm_states( struct x11drv_win_data *data )
if (!data->managed) return;
if (data->whole_window == root_window) return;
style = GetWindowLongW( data->hwnd, GWL_STYLE );
style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
if (style & WS_MINIMIZE)
new_state |= data->net_wm_state & ((1 << NET_WM_STATE_FULLSCREEN)|(1 << NET_WM_STATE_MAXIMIZED));
if (is_window_rect_full_screen( &data->whole_rect ))
@ -994,14 +998,14 @@ void update_net_wm_states( struct x11drv_win_data *data )
else if (style & WS_MAXIMIZE)
new_state |= (1 << NET_WM_STATE_MAXIMIZED);
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE );
if (ex_style & WS_EX_TOPMOST)
new_state |= (1 << NET_WM_STATE_ABOVE);
if (!data->add_taskbar)
{
if (data->skip_taskbar || (ex_style & (WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE)))
new_state |= (1 << NET_WM_STATE_SKIP_TASKBAR) | (1 << NET_WM_STATE_SKIP_PAGER);
else if (!(ex_style & WS_EX_APPWINDOW) && GetWindow( data->hwnd, GW_OWNER ))
else if (!(ex_style & WS_EX_APPWINDOW) && NtUserGetWindowRelative( data->hwnd, GW_OWNER ))
new_state |= (1 << NET_WM_STATE_SKIP_TASKBAR);
}
@ -1205,8 +1209,8 @@ static void get_decoration_rect( struct x11drv_win_data *data, RECT *rect,
SetRectEmpty( rect );
if (!data->managed) return;
style = GetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE );
decor = get_mwm_decorations( data, style, ex_style, window_rect, client_rect );
if (decor & MWM_DECOR_TITLE) style_mask |= WS_CAPTION;
@ -1272,8 +1276,8 @@ static void sync_window_position( struct x11drv_win_data *data,
UINT swp_flags, const RECT *old_window_rect,
const RECT *old_whole_rect, const RECT *old_client_rect )
{
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
DWORD ex_style = GetWindowLongW( data->hwnd, GWL_EXSTYLE );
DWORD style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
DWORD ex_style = NtUserGetWindowLongW( data->hwnd, GWL_EXSTYLE );
XWindowChanges changes;
unsigned int mask = 0;
@ -1303,9 +1307,9 @@ static void sync_window_position( struct x11drv_win_data *data,
if (!(swp_flags & SWP_NOZORDER) || (swp_flags & SWP_SHOWWINDOW))
{
/* find window that this one must be after */
HWND prev = GetWindow( data->hwnd, GW_HWNDPREV );
while (prev && !(GetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE))
prev = GetWindow( prev, GW_HWNDPREV );
HWND prev = NtUserGetWindowRelative( data->hwnd, GW_HWNDPREV );
while (prev && !(NtUserGetWindowLongW( prev, GWL_STYLE ) & WS_VISIBLE))
prev = NtUserGetWindowRelative( prev, GW_HWNDPREV );
if (!prev) /* top child */
{
changes.stack_mode = Above;
@ -1394,9 +1398,9 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co
if (!window)
{
OffsetRect( &dst_rect, -new_window_rect->left, -new_window_rect->top );
parent = GetAncestor( hwnd, GA_PARENT );
hdc_src = GetDCEx( parent, 0, DCX_CACHE );
hdc_dst = GetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
parent = NtUserGetAncestor( hwnd, GA_PARENT );
hdc_src = NtUserGetDCEx( parent, 0, DCX_CACHE );
hdc_dst = NtUserGetDCEx( hwnd, 0, DCX_CACHE | DCX_WINDOW );
}
else
{
@ -1404,7 +1408,7 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co
/* make src rect relative to the old position of the window */
OffsetRect( &src_rect, -old_client_rect->left, -old_client_rect->top );
if (dst_rect.left == src_rect.left && dst_rect.top == src_rect.top) return;
hdc_src = hdc_dst = GetDCEx( hwnd, 0, DCX_CACHE );
hdc_src = hdc_dst = NtUserGetDCEx( hwnd, 0, DCX_CACHE );
}
rgn = NtGdiCreateRectRgn( dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom );
@ -1415,7 +1419,7 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co
* child window contents from the copied parent window bits, but we
* still want to avoid copying invalid window bits when possible.
*/
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_CLIPCHILDREN ))
if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_CLIPCHILDREN ))
ExcludeUpdateRgn( hdc_dst, hwnd );
code = X11DRV_START_EXPOSURES;
@ -1431,8 +1435,8 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co
code = X11DRV_END_EXPOSURES;
NtGdiExtEscape( hdc_dst, NULL, 0, X11DRV_ESCAPE, sizeof(code), (LPSTR)&code, sizeof(rgn), (LPSTR)&rgn );
ReleaseDC( hwnd, hdc_dst );
if (hdc_src != hdc_dst) ReleaseDC( parent, hdc_src );
NtUserReleaseDC( hwnd, hdc_dst );
if (hdc_src != hdc_dst) NtUserReleaseDC( parent, hdc_src );
if (rgn)
{
@ -1441,10 +1445,10 @@ static void move_window_bits( HWND hwnd, Window window, const RECT *old_rect, co
/* map region to client rect since we are using DCX_WINDOW */
NtGdiOffsetRgn( rgn, new_window_rect->left - new_client_rect->left,
new_window_rect->top - new_client_rect->top );
RedrawWindow( hwnd, NULL, rgn,
RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN );
NtUserRedrawWindow( hwnd, NULL, rgn,
RDW_INVALIDATE | RDW_FRAME | RDW_ERASE | RDW_ALLCHILDREN );
}
else RedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
else NtUserRedrawWindow( hwnd, NULL, rgn, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN );
NtGdiDeleteObjectApp( rgn );
}
}
@ -1507,10 +1511,10 @@ Window create_client_window( HWND hwnd, const XVisualInfo *visual )
if (!data)
{
/* explicitly create data for HWND_MESSAGE windows since they can be used for OpenGL */
HWND parent = GetAncestor( hwnd, GA_PARENT );
if (parent == GetDesktopWindow() || GetAncestor( parent, GA_PARENT )) return 0;
HWND parent = NtUserGetAncestor( hwnd, GA_PARENT );
if (parent == NtUserGetDesktopWindow() || NtUserGetAncestor( parent, GA_PARENT )) return 0;
if (!(data = alloc_win_data( thread_init_display(), hwnd ))) return 0;
GetClientRect( hwnd, &data->client_rect );
NtUserGetClientRect( hwnd, &data->client_rect );
data->window_rect = data->whole_rect = data->client_rect;
}
@ -1577,7 +1581,8 @@ static void create_whole_window( struct x11drv_win_data *data )
data->managed = TRUE;
}
if ((win_rgn = NtGdiCreateRectRgn( 0, 0, 0, 0 )) && GetWindowRgn( data->hwnd, win_rgn ) == ERROR)
if ((win_rgn = NtGdiCreateRectRgn( 0, 0, 0, 0 )) &&
NtUserGetWindowRgnEx( data->hwnd, win_rgn, 0 ) == ERROR)
{
NtGdiDeleteObjectApp( win_rgn );
win_rgn = 0;
@ -1604,17 +1609,17 @@ static void create_whole_window( struct x11drv_win_data *data )
set_wm_hints( data );
XSaveContext( data->display, data->whole_window, winContext, (char *)data->hwnd );
SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
NtUserSetProp( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
/* set the window text */
if (!InternalGetWindowText( data->hwnd, text, ARRAY_SIZE( text ))) text[0] = 0;
if (!NtUserInternalGetWindowText( data->hwnd, text, ARRAY_SIZE( text ))) text[0] = 0;
sync_window_text( data->display, data->whole_window, text );
/* set the window region */
if (win_rgn || IsRectEmpty( &data->window_rect )) sync_window_region( data, win_rgn );
/* set the window opacity */
if (!GetLayeredWindowAttributes( data->hwnd, &key, &alpha, &layered_flags )) layered_flags = 0;
if (!NtUserGetLayeredWindowAttributes( data->hwnd, &key, &alpha, &layered_flags )) layered_flags = 0;
sync_window_opacity( data->display, data->whole_window, key, alpha, layered_flags );
XFlush( data->display ); /* make sure the window exists before we start painting to it */
@ -1641,12 +1646,12 @@ static void destroy_whole_window( struct x11drv_win_data *data, BOOL already_des
{
if (data->embedded)
{
Window xwin = (Window)GetPropA( data->hwnd, foreign_window_prop );
Window xwin = (Window)NtUserGetProp( data->hwnd, foreign_window_prop );
if (xwin)
{
if (!already_destroyed) XSelectInput( data->display, xwin, 0 );
XDeleteContext( data->display, xwin, winContext );
RemovePropA( data->hwnd, foreign_window_prop );
NtUserRemoveProp( data->hwnd, foreign_window_prop );
}
return;
}
@ -1678,7 +1683,7 @@ static void destroy_whole_window( struct x11drv_win_data *data, BOOL already_des
XFlush( data->display );
if (data->surface) window_surface_release( data->surface );
data->surface = NULL;
RemovePropA( data->hwnd, whole_window_prop );
NtUserRemoveProp( data->hwnd, whole_window_prop );
}
@ -1737,7 +1742,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
struct x11drv_win_data *data;
DWORD changed = style->styleNew ^ style->styleOld;
if (hwnd == GetDesktopWindow()) return;
if (hwnd == NtUserGetDesktopWindow()) return;
if (!(data = get_win_data( hwnd ))) return;
if (!data->whole_window) goto done;
@ -1794,7 +1799,7 @@ BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event )
destroy_whole_window( data, TRUE );
release_win_data( data );
if (embedded) SendMessageW( hwnd, WM_CLOSE, 0, 0 );
if (embedded) send_message( hwnd, WM_CLOSE, 0, 0 );
return TRUE;
}
@ -1806,10 +1811,10 @@ BOOL create_desktop_win_data( Window win )
Display *display = thread_data->display;
struct x11drv_win_data *data;
if (!(data = alloc_win_data( display, GetDesktopWindow() ))) return FALSE;
if (!(data = alloc_win_data( display, NtUserGetDesktopWindow() ))) return FALSE;
data->whole_window = win;
data->managed = TRUE;
SetPropA( data->hwnd, whole_window_prop, (HANDLE)win );
NtUserSetProp( data->hwnd, whole_window_prop, (HANDLE)win );
set_initial_wm_hints( display, win );
release_win_data( data );
if (thread_data->clip_window) XReparentWindow( display, thread_data->clip_window, win, 0, 0 );
@ -1854,7 +1859,7 @@ BOOL X11DRV_CreateDesktopWindow( HWND hwnd )
}
else
{
Window win = (Window)GetPropA( hwnd, whole_window_prop );
Window win = (Window)NtUserGetProp( hwnd, whole_window_prop );
if (win && win != root_window) X11DRV_init_desktop( win, width, height );
}
return TRUE;
@ -1886,10 +1891,10 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp,
break;
}
case WM_WINE_DELETE_TAB:
SendNotifyMessageW( (HWND)wp, WM_X11DRV_DELETE_TAB, 0, 0 );
send_notify_message( (HWND)wp, WM_X11DRV_DELETE_TAB, 0, 0 );
break;
case WM_WINE_ADD_TAB:
SendNotifyMessageW( (HWND)wp, WM_X11DRV_ADD_TAB, 0, 0 );
send_notify_message( (HWND)wp, WM_X11DRV_ADD_TAB, 0, 0 );
break;
}
return desktop_orig_wndproc( hwnd, msg, wp, lp );
@ -1900,13 +1905,13 @@ static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp,
*/
BOOL X11DRV_CreateWindow( HWND hwnd )
{
if (hwnd == GetDesktopWindow())
if (hwnd == NtUserGetDesktopWindow())
{
struct x11drv_thread_data *data = x11drv_init_thread_data();
XSetWindowAttributes attr;
desktop_orig_wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC,
(LONG_PTR)desktop_wndproc_wrapper );
desktop_orig_wndproc = (WNDPROC)NtUserSetWindowLongPtr( hwnd, GWLP_WNDPROC,
(LONG_PTR)desktop_wndproc_wrapper, FALSE );
/* create the cursor clipping window */
attr.override_redirect = TRUE;
@ -1915,7 +1920,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
InputOnly, default_visual.visual,
CWOverrideRedirect | CWEventMask, &attr );
XFlush( data->display );
SetPropA( hwnd, clip_window_prop, (HANDLE)data->clip_window );
NtUserSetProp( hwnd, clip_window_prop, (HANDLE)data->clip_window );
X11DRV_InitClipboard();
X11DRV_DisplayDevices_RegisterEventHandlers();
}
@ -1964,12 +1969,12 @@ static struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd, const RECT *wi
struct x11drv_win_data *data;
HWND parent;
if (!(parent = GetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop */
if (!(parent = NtUserGetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop */
/* don't create win data for HWND_MESSAGE windows */
if (parent != GetDesktopWindow() && !GetAncestor( parent, GA_PARENT )) return NULL;
if (parent != NtUserGetDesktopWindow() && !NtUserGetAncestor( parent, GA_PARENT )) return NULL;
if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId()) return NULL;
if (NtUserGetWindowThread( hwnd, NULL ) != GetCurrentThreadId()) return NULL;
/* Recreate the parent gl_drawable now that we know there are child windows
* that will need clipping support.
@ -1983,7 +1988,7 @@ static struct x11drv_win_data *X11DRV_create_win_data( HWND hwnd, const RECT *wi
data->whole_rect = data->window_rect = *window_rect;
data->client_rect = *client_rect;
if (parent == GetDesktopWindow())
if (parent == NtUserGetDesktopWindow())
{
create_whole_window( data );
TRACE( "win %p/%lx window %s whole %s client %s\n",
@ -2006,11 +2011,11 @@ static LRESULT WINAPI foreign_window_proc( HWND hwnd, UINT msg, WPARAM wparam, L
if (LOWORD(wparam) == WM_DESTROY)
{
TRACE( "%p: got parent notify destroy for win %lx\n", hwnd, lparam );
PostMessageW( hwnd, WM_CLOSE, 0, 0 ); /* so that we come back here once the child is gone */
NtUserPostMessage( hwnd, WM_CLOSE, 0, 0 ); /* so that we come back here once the child is gone */
}
return 0;
case WM_CLOSE:
if (GetWindow( hwnd, GW_CHILD )) return 0; /* refuse to die if we still have children */
if (NtUserGetWindowRelative( hwnd, GW_CHILD )) return 0; /* refuse to die if we still have children */
break;
}
return DefWindowProcW( hwnd, msg, wparam, lparam );
@ -2065,7 +2070,7 @@ HWND create_foreign_window( Display *display, Window xwin )
if (xparent == xroot)
{
parent = GetDesktopWindow();
parent = NtUserGetDesktopWindow();
style |= WS_POPUP;
pos = root_to_virtual_screen( attr.x, attr.y );
}
@ -2091,7 +2096,7 @@ HWND create_foreign_window( Display *display, Window xwin )
data->embedded = TRUE;
data->mapped = TRUE;
SetPropA( hwnd, foreign_window_prop, (HANDLE)xwin );
NtUserSetProp( hwnd, foreign_window_prop, (HANDLE)xwin );
XSaveContext( display, xwin, winContext, (char *)data->hwnd );
TRACE( "win %lx parent %p style %08x %s -> hwnd %p\n",
@ -2099,7 +2104,7 @@ HWND create_foreign_window( Display *display, Window xwin )
release_win_data( data );
ShowWindow( hwnd, SW_SHOW );
NtUserShowWindow( hwnd, SW_SHOW );
return hwnd;
}
@ -2116,8 +2121,8 @@ Window X11DRV_get_whole_window( HWND hwnd )
if (!data)
{
if (hwnd == GetDesktopWindow()) return root_window;
return (Window)GetPropA( hwnd, whole_window_prop );
if (hwnd == NtUserGetDesktopWindow()) return root_window;
return (Window)NtUserGetProp( hwnd, whole_window_prop );
}
ret = data->whole_window;
release_win_data( data );
@ -2177,7 +2182,7 @@ void X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
else
{
/* find the first ancestor that has a drawable */
for (parent = hwnd; parent && parent != top; parent = GetAncestor( parent, GA_PARENT ))
for (parent = hwnd; parent && parent != top; parent = NtUserGetAncestor( parent, GA_PARENT ))
if ((escape.drawable = X11DRV_get_whole_window( parent ))) break;
if (escape.drawable)
@ -2258,7 +2263,7 @@ void X11DRV_SetCapture( HWND hwnd, UINT flags )
if (hwnd)
{
if (!(data = get_win_data( GetAncestor( hwnd, GA_ROOT )))) return;
if (!(data = get_win_data( NtUserGetAncestor( hwnd, GA_ROOT )))) return;
if (data->whole_window)
{
XFlush( gdi_display );
@ -2292,9 +2297,9 @@ void X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
if (!(data = get_win_data( hwnd ))) return;
if (data->embedded) goto done;
if (parent != GetDesktopWindow()) /* a child window */
if (parent != NtUserGetDesktopWindow()) /* a child window */
{
if (old_parent == GetDesktopWindow())
if (old_parent == NtUserGetDesktopWindow())
{
/* destroy the old X windows */
destroy_whole_window( data, FALSE );
@ -2343,7 +2348,7 @@ BOOL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
RECT surface_rect;
DWORD flags;
COLORREF key;
BOOL layered = GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
if (!data && !(data = X11DRV_create_win_data( hwnd, window_rect, client_rect ))) return TRUE;
@ -2385,9 +2390,9 @@ BOOL X11DRV_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
goto done;
}
}
else if (!(swp_flags & SWP_SHOWWINDOW) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
else if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done;
if (!layered || !GetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY))
key = CLR_INVALID;
*surface = create_surface( data->whole_window, &data->vis, &surface_rect, key, FALSE );
@ -2408,7 +2413,7 @@ void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
{
struct x11drv_thread_data *thread_data;
struct x11drv_win_data *data;
DWORD new_style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD new_style = NtUserGetWindowLongW( hwnd, GWL_STYLE );
RECT old_window_rect, old_whole_rect, old_client_rect;
int event_type;
@ -2521,7 +2526,7 @@ void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
BOOL needs_map = TRUE;
/* layered windows are mapped only once their attributes are set */
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED)
if (NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED)
needs_map = data->layered || IsRectEmpty( rectWindow );
release_win_data( data );
if (needs_icon) fetch_icon_data( hwnd, 0, 0 );
@ -2561,7 +2566,7 @@ static BOOL hide_icon( struct x11drv_win_data *data )
if (data->managed) return TRUE;
/* hide icons in desktop mode when the taskbar is active */
if (!is_virtual_desktop()) return FALSE;
return IsWindowVisible( FindWindowW( trayW, NULL ));
return NtUserIsWindowVisible( FindWindowW( trayW, NULL ));
}
/***********************************************************************
@ -2573,7 +2578,7 @@ UINT X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
unsigned int width, height, border, depth;
Window root, top;
POINT pos;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD style = NtUserGetWindowLongW( hwnd, GWL_STYLE );
struct x11drv_thread_data *thread_data = x11drv_thread_data();
struct x11drv_win_data *data = get_win_data( hwnd );
@ -2655,7 +2660,7 @@ void X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
}
else if (X11DRV_get_whole_window( hwnd ))
{
SendMessageW( hwnd, WM_X11DRV_SET_WIN_REGION, 0, 0 );
send_message( hwnd, WM_X11DRV_SET_WIN_REGION, 0, 0 );
}
}
@ -2681,7 +2686,7 @@ void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO
data->layered = TRUE;
if (!data->mapped) /* mapping is delayed until attributes are set */
{
DWORD style = GetWindowLongW( data->hwnd, GWL_STYLE );
DWORD style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
if ((style & WS_VISIBLE) &&
((style & WS_MINIMIZE) || is_window_rect_mapped( &data->window_rect )))
@ -2749,7 +2754,7 @@ BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
/* layered windows are mapped only once their attributes are set */
if (!mapped)
{
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
DWORD style = NtUserGetWindowLongW( hwnd, GWL_STYLE );
if ((style & WS_VISIBLE) && ((style & WS_MINIMIZE) || is_window_rect_mapped( window_rect )))
map_window( hwnd, style );
@ -2945,7 +2950,7 @@ LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
if (!(data = get_win_data( hwnd )))
{
if (wparam == SC_SCREENSAVE && hwnd == GetDesktopWindow()) return start_screensaver();
if (wparam == SC_SCREENSAVE && hwnd == NtUserGetDesktopWindow()) return start_screensaver();
return -1;
}
if (!data->whole_window || !data->managed || !data->mapped) goto failed;
@ -2958,7 +2963,7 @@ LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
break;
case SC_SIZE:
/* windows without WS_THICKFRAME are not resizable through the window manager */
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_THICKFRAME)) goto failed;
if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_THICKFRAME)) goto failed;
switch (hittest)
{
@ -2979,8 +2984,8 @@ LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
/* prevent a simple ALT press+release from activating the system menu,
* as that can get confusing on managed windows */
if ((WCHAR)lparam) goto failed; /* got an explicit char */
if (GetMenu( hwnd )) goto failed; /* window has a real menu */
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) goto failed; /* no system menu */
if (NtUserGetWindowLongPtrW( hwnd, GWLP_ID )) goto failed; /* window has a real menu */
if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) goto failed; /* no system menu */
TRACE( "ignoring SC_KEYMENU wp %lx lp %lx\n", wparam, lparam );
release_win_data( data );
return 0;
@ -2989,7 +2994,7 @@ LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
goto failed;
}
if (IsZoomed(hwnd)) goto failed;
if (NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_MAXIMIZE) goto failed;
if (!is_netwm_supported( data->display, x11drv_atom(_NET_WM_MOVERESIZE) ))
{

View File

@ -850,6 +850,25 @@ static inline UINT get_palette_entries( HPALETTE palette, UINT start, UINT count
return NtGdiDoPalette( palette, start, count, entries, NtGdiGetPaletteEntries, TRUE );
}
/* user helpers */
static inline LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
return NtUserMessageCall( hwnd, msg, wparam, lparam, NULL, NtUserSendMessage, FALSE );
}
static inline BOOL send_notify_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
return NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserSendNotifyMessage, FALSE );
}
static inline HWND get_active_window(void)
{
GUITHREADINFO info;
info.cbSize = sizeof(info);
return NtUserGetGUIThreadInfo( GetCurrentThreadId(), &info ) ? info.hwndActive : 0;
}
/* registry helpers */
extern HKEY open_hkcu_key( const char *name ) DECLSPEC_HIDDEN;