winex11: Merge the iconification support into the SetWindowPos driver backend.

This commit is contained in:
Alexandre Julliard 2008-02-28 17:01:10 +01:00
parent cfcacdf554
commit 63dd1a02ca
3 changed files with 26 additions and 57 deletions

View File

@ -980,48 +980,6 @@ void X11DRV_set_wm_hints( Display *display, struct x11drv_win_data *data )
}
/***********************************************************************
* X11DRV_set_iconic_state
*
* Set the X11 iconic state according to the window style.
*/
void X11DRV_set_iconic_state( HWND hwnd )
{
Display *display = thread_display();
struct x11drv_win_data *data;
RECT rect;
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
BOOL iconic = (style & WS_MINIMIZE) != 0;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (!data->whole_window) return;
GetWindowRect( hwnd, &rect );
wine_tsx11_lock();
if (data->wm_hints)
{
data->wm_hints->flags |= StateHint | IconPositionHint;
data->wm_hints->initial_state = iconic ? IconicState : NormalState;
data->wm_hints->icon_x = rect.left - virtual_screen_rect.left;
data->wm_hints->icon_y = rect.top - virtual_screen_rect.top;
XSetWMHints( display, data->whole_window, data->wm_hints );
}
if (data->mapped)
{
if (iconic)
XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
else
if (X11DRV_is_window_rect_mapped( &rect ))
XMapWindow( display, data->whole_window );
}
wine_tsx11_unlock();
}
/***********************************************************************
* X11DRV_window_to_X_rect
*

View File

@ -159,6 +159,7 @@ void X11DRV_SetWindowStyle( HWND hwnd, DWORD old_style )
XMapWindow( display, data->whole_window );
wine_tsx11_unlock();
data->mapped = TRUE;
data->iconic = (new_style & WS_MINIMIZE) != 0;
}
}
}
@ -354,8 +355,8 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
SERVER_END_REQ;
}
TRACE( "win %p window %s client %s style %08x\n",
hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style );
TRACE( "win %p window %s client %s style %08x flags %08x\n",
hwnd, wine_dbgstr_rect(rectWindow), wine_dbgstr_rect(rectClient), new_style, swp_flags );
if (!IsRectEmpty( &valid_rects[0] ))
{
@ -395,12 +396,14 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
data->net_wm_state = 0;
}
X11DRV_sync_window_position( display, data, swp_flags, &old_client_rect, &old_whole_rect );
/* don't change position if we are about to minimize a managed window */
if (!(data->managed && (swp_flags & SWP_STATECHANGED) && (new_style & WS_MINIMIZE)))
X11DRV_sync_window_position( display, data, swp_flags, &old_client_rect, &old_whole_rect );
if ((new_style & WS_VISIBLE) && !(new_style & WS_MINIMIZE) &&
X11DRV_is_window_rect_mapped( rectWindow ))
if ((new_style & WS_VISIBLE) &&
((new_style & WS_MINIMIZE) || X11DRV_is_window_rect_mapped( rectWindow )))
{
if (!data->mapped || (swp_flags & SWP_FRAMECHANGED))
if (!data->mapped || (swp_flags & (SWP_FRAMECHANGED|SWP_STATECHANGED)))
X11DRV_set_wm_hints( display, data );
if (!data->mapped)
@ -413,6 +416,18 @@ void X11DRV_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
XFlush( display );
wine_tsx11_unlock();
data->mapped = TRUE;
data->iconic = (new_style & WS_MINIMIZE) != 0;
}
else if ((swp_flags & SWP_STATECHANGED) && (!data->iconic != !(new_style & WS_MINIMIZE)))
{
data->iconic = (new_style & WS_MINIMIZE) != 0;
TRACE( "changing win %p iconic state to %u\n", data->hwnd, data->iconic );
wine_tsx11_lock();
if (data->iconic)
XIconifyWindow( display, data->whole_window, DefaultScreen(display) );
else if (X11DRV_is_window_rect_mapped( rectWindow ))
XMapWindow( display, data->whole_window );
wine_tsx11_unlock();
}
update_net_wm_states( display, data );
}
@ -528,8 +543,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
old_style = WIN_SetStyle( hwnd, WS_MINIMIZE, WS_MAXIMIZE );
X11DRV_set_iconic_state( hwnd );
wpl.ptMinPosition = WINPOS_FindIconPos( hwnd, wpl.ptMinPosition );
if (!(old_style & WS_MINIMIZE)) swpFlags |= SWP_STATECHANGED;
@ -545,11 +558,8 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
WINPOS_GetMinMaxInfo( hwnd, &size, &wpl.ptMaxPosition, NULL, NULL );
old_style = WIN_SetStyle( hwnd, WS_MAXIMIZE, WS_MINIMIZE );
if (old_style & WS_MINIMIZE)
{
WINPOS_ShowIconTitle( hwnd, FALSE );
X11DRV_set_iconic_state( hwnd );
}
if (old_style & WS_MINIMIZE) WINPOS_ShowIconTitle( hwnd, FALSE );
if (!(old_style & WS_MAXIMIZE)) swpFlags |= SWP_STATECHANGED;
SetRect( rect, wpl.ptMaxPosition.x, wpl.ptMaxPosition.y, size.x, size.y );
break;
@ -563,7 +573,6 @@ UINT WINPOS_MinMaximize( HWND hwnd, UINT cmd, LPRECT rect )
BOOL restore_max;
WINPOS_ShowIconTitle( hwnd, FALSE );
X11DRV_set_iconic_state( hwnd );
if (!(wndPtr = WIN_GetPtr( hwnd )) || wndPtr == WND_OTHER_PROCESS) return 0;
restore_max = (wndPtr->flags & WIN_RESTORE_MAX) != 0;
@ -764,6 +773,7 @@ void X11DRV_MapNotify( HWND hwnd, XEvent *event )
TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state );
return;
}
data->iconic = FALSE;
if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) == (WS_VISIBLE|WS_MINIMIZE))
{
@ -818,6 +828,7 @@ void X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
TRACE( "win %p/%lx ignoring since state=%d\n", hwnd, data->whole_window, state );
return;
}
data->iconic = TRUE;
if (!(win = WIN_GetPtr( hwnd ))) return;

View File

@ -670,6 +670,7 @@ struct x11drv_win_data
XWMHints *wm_hints; /* window manager hints */
BOOL managed : 1; /* is window managed? */
BOOL mapped : 1; /* is window mapped? (in either normal or iconic state) */
BOOL iconic : 1; /* is window in iconic state? */
int wm_state; /* current value of the WM_STATE property */
DWORD net_wm_state; /* bit mask of active x11drv_net_wm_state values */
unsigned int lock_changes; /* lock count for X11 change requests */
@ -717,7 +718,6 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void
extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg );
extern int X11DRV_check_error(void);
extern BOOL is_window_managed( HWND hwnd, UINT swp_flags, const RECT *window_rect );
extern void X11DRV_set_iconic_state( HWND hwnd );
extern void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect );
extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect );
extern void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data );