Commit b8edf184 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11: Add a helper function to set input focus for non-managed windows.

parent 41d03165
......@@ -530,6 +530,31 @@ static inline BOOL can_activate_window( HWND hwnd )
/**********************************************************************
* set_input_focus
*
* Try to force focus for non-managed windows.
*/
static void set_input_focus( Display *display, Window window )
{
XWindowChanges changes;
DWORD timestamp;
if (!window) return;
if (EVENT_x11_time_to_win32_time(0))
/* ICCCM says don't use CurrentTime, so try to use last message time if possible */
/* FIXME: this is not entirely correct */
timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
else
timestamp = CurrentTime;
/* Set X focus and install colormap */
changes.stack_mode = Above;
XConfigureWindow( display, window, CWStackMode, &changes );
XSetInputFocus( display, window, RevertToParent, timestamp );
}
/**********************************************************************
* set_focus
*/
static void set_focus( Display *display, HWND hwnd, Time time )
......@@ -855,7 +880,8 @@ static void X11DRV_MapNotify( HWND hwnd, XEvent *event )
if (!data->managed)
{
HWND hwndFocus = GetFocus();
if (hwndFocus && IsChild( hwnd, hwndFocus )) X11DRV_SetFocus(hwndFocus); /* FIXME */
if (hwndFocus && IsChild( hwnd, hwndFocus ))
set_input_focus( thread_display(), data->whole_window );
}
}
......@@ -1240,6 +1266,22 @@ void wait_for_withdrawn_state( HWND hwnd, BOOL set )
}
/*****************************************************************
* SetFocus (X11DRV.@)
*
* Set the X focus.
*/
void CDECL X11DRV_SetFocus( HWND hwnd )
{
Display *display = thread_display();
struct x11drv_win_data *data;
if (!(hwnd = GetAncestor( hwnd, GA_ROOT ))) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (!data->managed) set_input_focus( display, data->whole_window );
}
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
{
RECT tempRect;
......
......@@ -1989,36 +1989,6 @@ void CDECL X11DRV_SetParent( HWND hwnd, HWND parent, HWND old_parent )
}
/*****************************************************************
* SetFocus (X11DRV.@)
*
* Set the X focus.
*/
void CDECL X11DRV_SetFocus( HWND hwnd )
{
Display *display = thread_display();
struct x11drv_win_data *data;
XWindowChanges changes;
DWORD timestamp;
if (!(hwnd = GetAncestor( hwnd, GA_ROOT ))) return;
if (!(data = X11DRV_get_win_data( hwnd ))) return;
if (data->managed || !data->whole_window) return;
if (EVENT_x11_time_to_win32_time(0))
/* ICCCM says don't use CurrentTime, so try to use last message time if possible */
/* FIXME: this is not entirely correct */
timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
else
timestamp = CurrentTime;
/* Set X focus and install colormap */
changes.stack_mode = Above;
XConfigureWindow( display, data->whole_window, CWStackMode, &changes );
XSetInputFocus( display, data->whole_window, RevertToParent, timestamp );
}
static inline RECT get_surface_rect( const RECT *visible_rect )
{
RECT rect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment