diff --git a/dlls/x11drv/event.c b/dlls/x11drv/event.c
index dfae906c437e0746896d819e978cc4065ac5990c..399ce347226922fbdde98e32e7062b54ef00a4dd 100644
--- a/dlls/x11drv/event.c
+++ b/dlls/x11drv/event.c
@@ -399,6 +399,7 @@ static void set_focus( HWND hwnd, Time time )
     SetForegroundWindow( hwnd );
 
     focus = GetFocus();
+    if (focus) focus = GetAncestor( focus, GA_ROOT );
     win = X11DRV_get_whole_window(focus);
 
     if (win)
@@ -451,6 +452,7 @@ static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
         else
         {
             hwnd = GetFocus();
+            if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
             if (!hwnd) hwnd = GetActiveWindow();
             if (!hwnd) hwnd = last_focus;
             if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, event_time );
@@ -486,6 +488,7 @@ static void EVENT_FocusIn( HWND hwnd, XFocusChangeEvent *event )
     if (!can_activate_window(hwnd))
     {
         HWND hwnd = GetFocus();
+        if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
         if (!hwnd) hwnd = GetActiveWindow();
         if (!hwnd) hwnd = x11drv_thread_data()->last_focus;
         if (hwnd && can_activate_window(hwnd)) set_focus( hwnd, CurrentTime );
diff --git a/dlls/x11drv/window.c b/dlls/x11drv/window.c
index f80f909509256cbe3a0ac8bdc07f858da418100d..74cf323dd2ba6cb4886ca7aac8162197419f3c6c 100644
--- a/dlls/x11drv/window.c
+++ b/dlls/x11drv/window.c
@@ -116,11 +116,12 @@ static int get_window_attributes( Display *display, WND *win, XSetWindowAttribut
     attr->colormap          = X11DRV_PALETTE_PaletteXColormap;
     attr->save_under        = ((win->clsStyle & CS_SAVEBITS) != 0);
     attr->cursor            = x11drv_thread_data()->cursor;
-    attr->event_mask        = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
+    attr->event_mask        = (ExposureMask | PointerMotionMask |
                                ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
 
     if (is_window_top_level( win ))
-        attr->event_mask |= StructureNotifyMask | FocusChangeMask | KeymapStateMask;
+        attr->event_mask |= (KeyPressMask | KeyReleaseMask | StructureNotifyMask |
+                             FocusChangeMask | KeymapStateMask);
 
     return (CWOverrideRedirect | CWSaveUnder | CWEventMask | CWColormap | CWCursor);
 }
@@ -717,7 +718,7 @@ static Window create_client_window( Display *display, WND *win )
     OffsetRect( &rect, -data->whole_rect.left, -data->whole_rect.top );
     data->client_rect = rect;
 
-    attr.event_mask = (ExposureMask | KeyPressMask | KeyReleaseMask | PointerMotionMask |
+    attr.event_mask = (ExposureMask | PointerMotionMask |
                        ButtonPressMask | ButtonReleaseMask | EnterWindowMask);
     attr.bit_gravity = (win->clsStyle & (CS_VREDRAW | CS_HREDRAW)) ?
                        ForgetGravity : NorthWestGravity;