Make WIN_SetStyle more thread-safe by specifying the bits to change
instead of the new value.
This commit is contained in:
parent
49a6c097b3
commit
f936428601
|
@ -418,9 +418,9 @@ BOOL TTYDRV_SetWindowPos( WINDOWPOS *winpos )
|
|||
&newWindowRect, &newClientRect, winpos->flags, wvrFlags );
|
||||
|
||||
if( winpos->flags & SWP_SHOWWINDOW )
|
||||
WIN_SetStyle( winpos->hwnd, wndPtr->dwStyle | WS_VISIBLE );
|
||||
WIN_SetStyle( winpos->hwnd, WS_VISIBLE, 0 );
|
||||
else if( winpos->flags & SWP_HIDEWINDOW )
|
||||
WIN_SetStyle( winpos->hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
|
||||
WIN_SetStyle( winpos->hwnd, 0, WS_VISIBLE );
|
||||
|
||||
/* ------------------------------------------------------------------------ FINAL */
|
||||
|
||||
|
|
|
@ -1793,10 +1793,9 @@ BOOL WINAPI GetScrollRange(HWND hwnd, INT nBar, LPINT lpMin, LPINT lpMax)
|
|||
*
|
||||
* Back-end for ShowScrollBar(). Returns FALSE if no action was taken.
|
||||
*/
|
||||
BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
|
||||
BOOL fShowH, BOOL fShowV )
|
||||
static BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar, BOOL fShowH, BOOL fShowV )
|
||||
{
|
||||
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
||||
ULONG old_style, set_bits = 0, clear_bits = 0;
|
||||
|
||||
TRACE("hwnd=%p bar=%d horz=%d, vert=%d\n", hwnd, nBar, fShowH, fShowV );
|
||||
|
||||
|
@ -1808,45 +1807,24 @@ BOOL SCROLL_ShowScrollBar( HWND hwnd, INT nBar,
|
|||
|
||||
case SB_BOTH:
|
||||
case SB_HORZ:
|
||||
if (fShowH)
|
||||
{
|
||||
fShowH = !(style & WS_HSCROLL);
|
||||
style |= WS_HSCROLL;
|
||||
}
|
||||
else /* hide it */
|
||||
{
|
||||
fShowH = (style & WS_HSCROLL);
|
||||
style &= ~WS_HSCROLL;
|
||||
}
|
||||
if( nBar == SB_HORZ ) {
|
||||
fShowV = FALSE;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
|
||||
if (fShowH) set_bits |= WS_HSCROLL;
|
||||
else clear_bits |= WS_HSCROLL;
|
||||
if( nBar == SB_HORZ ) break;
|
||||
/* fall through */
|
||||
case SB_VERT:
|
||||
if (fShowV)
|
||||
{
|
||||
fShowV = !(style & WS_VSCROLL);
|
||||
style |= WS_VSCROLL;
|
||||
}
|
||||
else /* hide it */
|
||||
{
|
||||
fShowV = (style & WS_VSCROLL);
|
||||
style &= ~WS_VSCROLL;
|
||||
}
|
||||
if ( nBar == SB_VERT )
|
||||
fShowH = FALSE;
|
||||
if (fShowV) set_bits |= WS_VSCROLL;
|
||||
else clear_bits |= WS_VSCROLL;
|
||||
break;
|
||||
|
||||
default:
|
||||
return FALSE; /* Nothing to do! */
|
||||
}
|
||||
|
||||
if( fShowH || fShowV ) /* frame has been changed, let the window redraw itself */
|
||||
old_style = WIN_SetStyle( hwnd, set_bits, clear_bits );
|
||||
if ((old_style & clear_bits) != 0 || (old_style & set_bits) != set_bits)
|
||||
{
|
||||
WIN_SetStyle( hwnd, style );
|
||||
SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
|
||||
/* frame has been changed, let the window redraw itself */
|
||||
SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE
|
||||
| SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -738,5 +738,5 @@
|
|||
@ cdecl WIN_ListParents(long)
|
||||
@ cdecl WIN_ReleaseWndPtr(ptr)
|
||||
@ cdecl WIN_SetExStyle(long long)
|
||||
@ cdecl WIN_SetStyle(long long)
|
||||
@ cdecl WIN_SetStyle(long long long)
|
||||
@ cdecl WIN_UnlinkWindow(long)
|
||||
|
|
|
@ -1155,7 +1155,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
|
|||
|
||||
RECT newPos;
|
||||
UINT swFlag = (style & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE;
|
||||
WIN_SetStyle( hwnd, style & ~(WS_MAXIMIZE | WS_MINIMIZE) );
|
||||
WIN_SetStyle( hwnd, 0, WS_MAXIMIZE | WS_MINIMIZE );
|
||||
WINPOS_MinMaximize( hwnd, swFlag, &newPos );
|
||||
swFlag = ((style & WS_CHILD) || GetActiveWindow())
|
||||
? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED
|
||||
|
|
|
@ -995,7 +995,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|||
if( wndPtr->dwStyle & WS_MAXIMIZE) wndPtr->flags |= WIN_RESTORE_MAX;
|
||||
else wndPtr->flags &= ~WIN_RESTORE_MAX;
|
||||
|
||||
WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE );
|
||||
WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
|
||||
|
||||
X11DRV_set_iconic_state( hwnd );
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|||
case SW_MAXIMIZE:
|
||||
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL );
|
||||
|
||||
old_style = WIN_SetStyle( hwnd, (wndPtr->dwStyle & ~WS_MINIMIZE) | WS_MAXIMIZE );
|
||||
old_style = WIN_SetStyle( hwnd, WS_MAXIMIZE, WS_MINIMIZE );
|
||||
if (old_style & WS_MINIMIZE)
|
||||
{
|
||||
WINPOS_ShowIconTitle( hwnd, FALSE );
|
||||
|
@ -1019,7 +1019,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|||
break;
|
||||
|
||||
case SW_RESTORE:
|
||||
old_style = WIN_SetStyle( hwnd, wndPtr->dwStyle & ~(WS_MINIMIZE|WS_MAXIMIZE) );
|
||||
old_style = WIN_SetStyle( hwnd, 0, WS_MINIMIZE | WS_MAXIMIZE );
|
||||
if (old_style & WS_MINIMIZE)
|
||||
{
|
||||
WINPOS_ShowIconTitle( hwnd, FALSE );
|
||||
|
@ -1029,7 +1029,7 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
|
|||
{
|
||||
/* Restore to maximized position */
|
||||
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL);
|
||||
WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_MAXIMIZE );
|
||||
WIN_SetStyle( hwnd, WS_MAXIMIZE, 0 );
|
||||
SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y );
|
||||
break;
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
|
|||
unsigned int width, height, border, depth;
|
||||
Window root, top;
|
||||
RECT rect;
|
||||
LONG style = (win->dwStyle & ~(WS_MINIMIZE|WS_MAXIMIZE)) | WS_VISIBLE;
|
||||
LONG style = WS_VISIBLE;
|
||||
|
||||
/* FIXME: hack */
|
||||
wine_tsx11_lock();
|
||||
|
@ -1215,7 +1215,7 @@ void X11DRV_MapNotify( HWND hwnd, XMapEvent *event )
|
|||
DCE_InvalidateDCE( hwnd, &win->rectWindow );
|
||||
|
||||
if (win->flags & WIN_RESTORE_MAX) style |= WS_MAXIMIZE;
|
||||
WIN_SetStyle( hwnd, style );
|
||||
WIN_SetStyle( hwnd, style, WS_MINIMIZE );
|
||||
WIN_ReleasePtr( win );
|
||||
|
||||
SendMessageA( hwnd, WM_SHOWWINDOW, SW_RESTORE, 0 );
|
||||
|
@ -1244,7 +1244,7 @@ void X11DRV_UnmapNotify( HWND hwnd, XUnmapEvent *event )
|
|||
else
|
||||
win->flags &= ~WIN_RESTORE_MAX;
|
||||
|
||||
WIN_SetStyle( hwnd, (win->dwStyle & ~WS_MAXIMIZE) | WS_MINIMIZE );
|
||||
WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
|
||||
WIN_ReleasePtr( win );
|
||||
|
||||
EndMenu();
|
||||
|
|
|
@ -87,7 +87,7 @@ extern HWND WIN_IsCurrentThread( HWND hwnd );
|
|||
extern void WIN_LinkWindow( HWND hwnd, HWND parent, HWND hwndInsertAfter );
|
||||
extern void WIN_UnlinkWindow( HWND hwnd );
|
||||
extern HWND WIN_SetOwner( HWND hwnd, HWND owner );
|
||||
extern LONG WIN_SetStyle( HWND hwnd, LONG style );
|
||||
extern ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits );
|
||||
extern LONG WIN_SetExStyle( HWND hwnd, LONG style );
|
||||
extern BOOL WIN_GetRectangles( HWND hwnd, RECT *rectWindow, RECT *rectClient );
|
||||
extern LRESULT WIN_DestroyWindow( HWND hwnd );
|
||||
|
|
|
@ -184,34 +184,6 @@ HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* DEFWND_SetRedraw
|
||||
*/
|
||||
static void DEFWND_SetRedraw( HWND hwnd, WPARAM wParam )
|
||||
{
|
||||
WND *wndPtr = WIN_FindWndPtr( hwnd );
|
||||
BOOL bVisible = wndPtr->dwStyle & WS_VISIBLE;
|
||||
|
||||
TRACE("%p %i\n", hwnd, (wParam!=0) );
|
||||
|
||||
if( wParam )
|
||||
{
|
||||
if( !bVisible )
|
||||
{
|
||||
WIN_SetStyle( hwnd, wndPtr->dwStyle | WS_VISIBLE );
|
||||
}
|
||||
}
|
||||
else if( bVisible )
|
||||
{
|
||||
if( wndPtr->dwStyle & WS_MINIMIZE ) wParam = RDW_VALIDATE;
|
||||
else wParam = RDW_ALLCHILDREN | RDW_VALIDATE;
|
||||
|
||||
RedrawWindow( hwnd, NULL, 0, wParam );
|
||||
WIN_SetStyle( hwnd, wndPtr->dwStyle & ~WS_VISIBLE );
|
||||
}
|
||||
WIN_ReleaseWndPtr( wndPtr );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DEFWND_Print
|
||||
*
|
||||
|
@ -463,7 +435,12 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
return 0;
|
||||
|
||||
case WM_SETREDRAW:
|
||||
DEFWND_SetRedraw( hwnd, wParam );
|
||||
if (wParam) WIN_SetStyle( hwnd, WS_VISIBLE, 0 );
|
||||
else
|
||||
{
|
||||
RedrawWindow( hwnd, NULL, 0, RDW_ALLCHILDREN | RDW_VALIDATE );
|
||||
WIN_SetStyle( hwnd, 0, WS_VISIBLE );
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_CLOSE:
|
||||
|
|
|
@ -462,40 +462,42 @@ HWND WIN_SetOwner( HWND hwnd, HWND owner )
|
|||
*
|
||||
* Change the style of a window.
|
||||
*/
|
||||
LONG WIN_SetStyle( HWND hwnd, LONG style )
|
||||
ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits )
|
||||
{
|
||||
BOOL ok;
|
||||
LONG ret = 0;
|
||||
ULONG new_style, old_style = 0;
|
||||
WND *win = WIN_GetPtr( hwnd );
|
||||
|
||||
if (!win) return 0;
|
||||
if (win == WND_OTHER_PROCESS)
|
||||
{
|
||||
if (IsWindow(hwnd))
|
||||
ERR( "cannot set style %lx on other process window %p\n", style, hwnd );
|
||||
ERR( "cannot set style %lx/%lx on other process window %p\n",
|
||||
set_bits, clear_bits, hwnd );
|
||||
return 0;
|
||||
}
|
||||
if (style == win->dwStyle)
|
||||
new_style = (win->dwStyle | set_bits) & ~clear_bits;
|
||||
if (new_style == win->dwStyle)
|
||||
{
|
||||
WIN_ReleasePtr( win );
|
||||
return style;
|
||||
return new_style;
|
||||
}
|
||||
SERVER_START_REQ( set_window_info )
|
||||
{
|
||||
req->handle = hwnd;
|
||||
req->flags = SET_WIN_STYLE;
|
||||
req->style = style;
|
||||
req->style = new_style;
|
||||
req->extra_offset = -1;
|
||||
if ((ok = !wine_server_call( req )))
|
||||
{
|
||||
ret = reply->old_style;
|
||||
win->dwStyle = style;
|
||||
old_style = reply->old_style;
|
||||
win->dwStyle = new_style;
|
||||
}
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
WIN_ReleasePtr( win );
|
||||
if (ok && USER_Driver.pSetWindowStyle) USER_Driver.pSetWindowStyle( hwnd, ret );
|
||||
return ret;
|
||||
if (ok && USER_Driver.pSetWindowStyle) USER_Driver.pSetWindowStyle( hwnd, old_style );
|
||||
return old_style;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1685,9 +1687,7 @@ HWND WINAPI GetDesktopWindow(void)
|
|||
*/
|
||||
BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
|
||||
{
|
||||
WND *wndPtr;
|
||||
BOOL retvalue;
|
||||
LONG style;
|
||||
HWND full_handle;
|
||||
|
||||
if (is_broadcast(hwnd))
|
||||
|
@ -1703,14 +1703,11 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
|
|||
|
||||
TRACE("( %p, %d )\n", hwnd, enable);
|
||||
|
||||
if (!(wndPtr = WIN_GetPtr( hwnd ))) return FALSE;
|
||||
style = wndPtr->dwStyle;
|
||||
retvalue = ((style & WS_DISABLED) != 0);
|
||||
WIN_ReleasePtr( wndPtr );
|
||||
retvalue = !IsWindowEnabled( hwnd );
|
||||
|
||||
if (enable && retvalue)
|
||||
{
|
||||
WIN_SetStyle( hwnd, style & ~WS_DISABLED );
|
||||
WIN_SetStyle( hwnd, 0, WS_DISABLED );
|
||||
SendMessageA( hwnd, WM_ENABLE, TRUE, 0 );
|
||||
}
|
||||
else if (!enable && !retvalue)
|
||||
|
@ -1719,7 +1716,7 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable )
|
|||
|
||||
SendMessageA( hwnd, WM_CANCELMODE, 0, 0);
|
||||
|
||||
WIN_SetStyle( hwnd, style | WS_DISABLED );
|
||||
WIN_SetStyle( hwnd, WS_DISABLED, 0 );
|
||||
|
||||
if (hwnd == GetFocus())
|
||||
SetFocus( 0 ); /* A disabled window can't have the focus */
|
||||
|
|
Loading…
Reference in New Issue