Skip to content

Commit

Permalink
winex11.drv: Ignore FocusOut event from intermediate unmap on Gamescope.
Browse files Browse the repository at this point in the history
CW-Bug-Id: #22953
  • Loading branch information
Paul Gofman authored and Paul Gofman committed Dec 6, 2023
1 parent e4bf8b4 commit aa53e1a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dlls/winex11.drv/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,9 +1008,21 @@ static void focus_out( Display *display , HWND hwnd )
static BOOL X11DRV_FocusOut( HWND hwnd, XEvent *xev )
{
XFocusChangeEvent *event = &xev->xfocus;
struct x11drv_win_data *data;

TRACE( "win %p xwin %lx detail=%s mode=%s\n", hwnd, event->window, focus_details[event->detail], focus_modes[event->mode] );

if ((data = get_win_data( hwnd )))
{
if (data->fake_unmap_serial == event->serial)
{
release_win_data( data );
TRACE( "Ignoring event from intermediate unmap.\n" );
return FALSE;
}
release_win_data( data );
}

if (event->detail == NotifyPointer)
{
if (!hwnd && event->window == x11drv_thread_data()->clip_window)
Expand Down
7 changes: 7 additions & 0 deletions dlls/winex11.drv/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -3335,7 +3335,14 @@ void X11DRV_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
/* whole_window could be both iconic and mapped. Since XMapWindow() doesn't do
* anything if the window is already mapped, we need to unmap it first */
if (data->mapped)
{
if (wm_is_steamcompmgr( data->display ))
{
/* Gamescope will generate FocusOut event upon processing UnmapNotify. Ignore it. */
data->fake_unmap_serial = NextRequest( data->display );
}
XUnmapWindow( data->display, data->whole_window );
}
XMapWindow( data->display, data->whole_window );
}
update_net_wm_states( data );
Expand Down
1 change: 1 addition & 0 deletions dlls/winex11.drv/x11drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ struct x11drv_win_data
DWORD net_wm_state; /* bit mask of active x11drv_net_wm_state values */
Window embedder; /* window id of embedder */
unsigned long unmapnotify_serial; /* serial number of last UnmapNotify event */
unsigned long fake_unmap_serial; /* serial number of unmap before map for restoring window from minimized state in X11DRV_WindowPosChanged() */
unsigned long configure_serial; /* serial number of last configure request */
struct window_surface *surface;
Pixmap icon_pixmap;
Expand Down

0 comments on commit aa53e1a

Please sign in to comment.