mirror of
https://gitlab.winehq.org/wine/wine.git
synced 2024-11-19 17:06:04 -07:00
winex11: Introduce a new window_update_client_state helper.
This commit is contained in:
parent
da936bcf35
commit
d9cf4678a1
Notes:
Alexandre Julliard
2024-11-15 22:25:39 +01:00
Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6820
3 changed files with 42 additions and 38 deletions
|
@ -1257,7 +1257,7 @@ static int get_window_xembed_info( Display *display, Window window )
|
|||
static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL update_window )
|
||||
{
|
||||
struct x11drv_win_data *data;
|
||||
UINT style, value = 0, state_cmd = 0;
|
||||
UINT value = 0, state_cmd = 0;
|
||||
|
||||
if (!(data = get_win_data( hwnd ))) return;
|
||||
if (event->state == PropertyNewValue) value = get_window_wm_state( event->display, event->window );
|
||||
|
@ -1278,49 +1278,13 @@ static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL updat
|
|||
TRACE( "%p/%lx: new WM_STATE %d from %d\n",
|
||||
data->hwnd, data->whole_window, new_state, old_state );
|
||||
data->wm_state = new_state;
|
||||
/* ignore the initial state transition out of withdrawn state */
|
||||
/* metacity does Withdrawn->NormalState->IconicState when mapping an iconic window */
|
||||
if (!old_state) goto done;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!update_window || !data->managed || !data->mapped) goto done;
|
||||
if (update_window) state_cmd = window_update_client_state( data );
|
||||
|
||||
style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
|
||||
|
||||
if (data->iconic && data->current_state.wm_state == NormalState) /* restore window */
|
||||
{
|
||||
data->iconic = FALSE;
|
||||
if ((style & WS_CAPTION) == WS_CAPTION && (data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)))
|
||||
{
|
||||
if ((style & WS_MAXIMIZEBOX) && !(style & WS_DISABLED))
|
||||
{
|
||||
TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window );
|
||||
state_cmd = SC_MAXIMIZE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
|
||||
{
|
||||
BOOL activate = (style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE);
|
||||
TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window );
|
||||
state_cmd = MAKELONG(SC_RESTORE, activate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!data->iconic && data->current_state.wm_state == IconicState)
|
||||
{
|
||||
data->iconic = TRUE;
|
||||
if ((style & WS_MINIMIZEBOX) && !(style & WS_DISABLED))
|
||||
{
|
||||
TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window );
|
||||
state_cmd = SC_MINIMIZE;
|
||||
}
|
||||
}
|
||||
done:
|
||||
release_win_data( data );
|
||||
|
||||
if (state_cmd)
|
||||
|
|
|
@ -1493,6 +1493,44 @@ static void unmap_window( HWND hwnd )
|
|||
release_win_data( data );
|
||||
}
|
||||
|
||||
UINT window_update_client_state( struct x11drv_win_data *data )
|
||||
{
|
||||
UINT old_style = NtUserGetWindowLongW( data->hwnd, GWL_STYLE );
|
||||
|
||||
if (!data->managed) return 0; /* unmanaged windows are managed by the Win32 side */
|
||||
if (!data->mapped) return 0; /* ignore state changes on invisible windows */
|
||||
|
||||
if (data->iconic && data->current_state.wm_state == NormalState) /* restore window */
|
||||
{
|
||||
data->iconic = FALSE;
|
||||
if ((old_style & WS_CAPTION) == WS_CAPTION && (data->current_state.net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)))
|
||||
{
|
||||
if ((old_style & WS_MAXIMIZEBOX) && !(old_style & WS_DISABLED))
|
||||
{
|
||||
TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window );
|
||||
return SC_MAXIMIZE;
|
||||
}
|
||||
}
|
||||
else if (old_style & (WS_MINIMIZE | WS_MAXIMIZE))
|
||||
{
|
||||
BOOL activate = (old_style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE);
|
||||
TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window );
|
||||
return MAKELONG(SC_RESTORE, activate);
|
||||
}
|
||||
}
|
||||
else if (!data->iconic && data->current_state.wm_state == IconicState)
|
||||
{
|
||||
data->iconic = TRUE;
|
||||
if ((old_style & WS_MINIMIZEBOX) && !(old_style & WS_DISABLED))
|
||||
{
|
||||
TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window );
|
||||
return SC_MINIMIZE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void window_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value )
|
||||
{
|
||||
UINT *pending = &data->pending_state.wm_state, *current = &data->current_state.wm_state;
|
||||
|
|
|
@ -662,6 +662,8 @@ extern BOOL window_has_pending_wm_state( HWND hwnd, UINT state );
|
|||
extern void window_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value );
|
||||
extern void window_net_wm_state_notify( struct x11drv_win_data *data, unsigned long serial, UINT value );
|
||||
extern void window_configure_notify( struct x11drv_win_data *data, unsigned long serial, const RECT *rect );
|
||||
extern UINT window_update_client_state( struct x11drv_win_data *data );
|
||||
|
||||
extern void wait_for_withdrawn_state( HWND hwnd, BOOL set );
|
||||
extern Window init_clip_window(void);
|
||||
extern void update_user_time( Time time );
|
||||
|
|
Loading…
Reference in a new issue