Commit 9387be62 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Call XSetInputFocus after XRaiseWindow when activating.

XRaiseWindow does not reliably set the focus. GTK code is doing the same
thing, see gdk/x11/gdkwindow-x11.c.

BUG=None

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=244779

Review URL: https://codereview.chromium.org/137533006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245231 0039d316-1c4b-4281-b951-d872f2087c98
parent c85939c4
......@@ -468,6 +468,9 @@ void DesktopWindowTreeHostX11::SetShape(gfx::NativeRegion native_region) {
}
void DesktopWindowTreeHostX11::Activate() {
if (!window_mapped_)
return;
X11DesktopHandler::get()->ActivateWindow(xwindow_);
native_widget_delegate_->AsWidget()->SetInitialFocus();
}
......
......@@ -199,29 +199,35 @@ TEST_F(DesktopScreenX11Test, GetPrimaryDisplay) {
}
TEST_F(DesktopScreenX11Test, GetWindowAtScreenPoint) {
Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(10, 10, 10, 10));
Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(50, 50, 10, 10));
Widget* window_three = BuildTopLevelDesktopWidget(gfx::Rect(15, 15, 20, 20));
Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(110, 110, 10, 10));
Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(150, 150, 10, 10));
Widget* window_three =
BuildTopLevelDesktopWidget(gfx::Rect(115, 115, 20, 20));
window_three->Show();
window_two->Show();
window_one->Show();
// Make sure the internal state of DesktopWindowTreeHostX11 is set up
// correctly.
ASSERT_EQ(3u, DesktopWindowTreeHostX11::GetAllOpenWindows().size());
EXPECT_EQ(window_one->GetNativeWindow(),
screen()->GetWindowAtScreenPoint(gfx::Point(15, 15)));
screen()->GetWindowAtScreenPoint(gfx::Point(115, 115)));
EXPECT_EQ(window_two->GetNativeWindow(),
screen()->GetWindowAtScreenPoint(gfx::Point(55, 55)));
screen()->GetWindowAtScreenPoint(gfx::Point(155, 155)));
EXPECT_EQ(NULL,
screen()->GetWindowAtScreenPoint(gfx::Point(100, 100)));
screen()->GetWindowAtScreenPoint(gfx::Point(200, 200)));
// Bring the third window in front. It overlaps with the first window.
// Hit-testing on the intersecting region should give the third window.
window_three->Activate();
EXPECT_EQ(window_three->GetNativeWindow(),
screen()->GetWindowAtScreenPoint(gfx::Point(15, 15)));
screen()->GetWindowAtScreenPoint(gfx::Point(115, 115)));
window_one->CloseNow();
window_two->CloseNow();
window_three->CloseNow();
}
TEST_F(DesktopScreenX11Test, GetDisplayNearestWindow) {
......
......@@ -94,6 +94,12 @@ void X11DesktopHandler::ActivateWindow(::Window window) {
&xclient);
} else {
XRaiseWindow(xdisplay_, window);
// XRaiseWindow will not give input focus to the window. We now need to ask
// the X server to do that. Note that the call will raise an X error if the
// window is not mapped.
XSetInputFocus(xdisplay_, window, RevertToParent, CurrentTime);
OnActiveWindowChanged(window);
}
}
......
......@@ -29,6 +29,7 @@ class VIEWS_EXPORT X11DesktopHandler : public base::MessagePumpDispatcher,
static X11DesktopHandler* get();
// Sends a request to the window manager to activate |window|.
// This method should only be called if the window is already mapped.
void ActivateWindow(::Window window);
// Checks if the current active window is |window|.
......
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