| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <gflags/gflags.h> | 5 #include <gflags/gflags.h> |
| 6 #include <gtest/gtest.h> | 6 #include <gtest/gtest.h> |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "window_manager/clutter_interface.h" | 10 #include "window_manager/clutter_interface.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_EQ(None, xconn_->focused_xid()); | 123 EXPECT_EQ(None, xconn_->focused_xid()); |
| 124 EXPECT_TRUE(lm_->active_toplevel_ == NULL); | 124 EXPECT_TRUE(lm_->active_toplevel_ == NULL); |
| 125 | 125 |
| 126 // The layout manager should activate and focus the window when it gets | 126 // The layout manager should activate and focus the window when it gets |
| 127 // mapped. | 127 // mapped. |
| 128 MockXConnection::InitMapEvent(&event, xid); | 128 MockXConnection::InitMapEvent(&event, xid); |
| 129 EXPECT_TRUE(wm_->HandleEvent(&event)); | 129 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 130 EXPECT_EQ(xid, xconn_->focused_xid()); | 130 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 131 ASSERT_TRUE(lm_->active_toplevel_ != NULL); | 131 ASSERT_TRUE(lm_->active_toplevel_ != NULL); |
| 132 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); | 132 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); |
| 133 EXPECT_EQ(None, wm_->active_window_xid()); | 133 EXPECT_EQ(None, GetActiveWindowProperty()); |
| 134 EXPECT_TRUE(info->all_buttons_grabbed); | 134 EXPECT_TRUE(info->all_buttons_grabbed); |
| 135 | 135 |
| 136 // We shouldn't actually update _NET_ACTIVE_WINDOW and remove the passive | 136 // We shouldn't actually update _NET_ACTIVE_WINDOW and remove the passive |
| 137 // button grab until we get the FocusIn event. | 137 // button grab until we get the FocusIn event. |
| 138 SendFocusEvents(xconn_->GetRootWindow(), xid); | 138 SendFocusEvents(xconn_->GetRootWindow(), xid); |
| 139 EXPECT_EQ(xid, wm_->active_window_xid()); | 139 EXPECT_EQ(xid, GetActiveWindowProperty()); |
| 140 EXPECT_FALSE(info->all_buttons_grabbed); | 140 EXPECT_FALSE(info->all_buttons_grabbed); |
| 141 | 141 |
| 142 // Now create a second window. | 142 // Now create a second window. |
| 143 XWindow xid2 = CreateSimpleWindow(); | 143 XWindow xid2 = CreateSimpleWindow(); |
| 144 MockXConnection::WindowInfo* info2 = xconn_->GetWindowInfoOrDie(xid2); | 144 MockXConnection::WindowInfo* info2 = xconn_->GetWindowInfoOrDie(xid2); |
| 145 | 145 |
| 146 // When the second window is created, the first should still be active. | 146 // When the second window is created, the first should still be active. |
| 147 MockXConnection::InitCreateWindowEvent(&event, *info2); | 147 MockXConnection::InitCreateWindowEvent(&event, *info2); |
| 148 EXPECT_TRUE(wm_->HandleEvent(&event)); | 148 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 149 EXPECT_EQ(xid, xconn_->focused_xid()); | 149 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 150 ASSERT_TRUE(lm_->active_toplevel_ != NULL); | 150 ASSERT_TRUE(lm_->active_toplevel_ != NULL); |
| 151 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); | 151 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); |
| 152 | 152 |
| 153 // When the second window is mapped, it should become the active window. | 153 // When the second window is mapped, it should become the active window. |
| 154 MockXConnection::InitMapEvent(&event, xid2); | 154 MockXConnection::InitMapEvent(&event, xid2); |
| 155 EXPECT_TRUE(wm_->HandleEvent(&event)); | 155 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 156 EXPECT_EQ(xid2, xconn_->focused_xid()); | 156 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 157 ASSERT_TRUE(lm_->active_toplevel_ != NULL); | 157 ASSERT_TRUE(lm_->active_toplevel_ != NULL); |
| 158 EXPECT_EQ(xid2, lm_->active_toplevel_->win()->xid()); | 158 EXPECT_EQ(xid2, lm_->active_toplevel_->win()->xid()); |
| 159 EXPECT_FALSE(info->all_buttons_grabbed); | 159 EXPECT_FALSE(info->all_buttons_grabbed); |
| 160 EXPECT_TRUE(info2->all_buttons_grabbed); | 160 EXPECT_TRUE(info2->all_buttons_grabbed); |
| 161 | 161 |
| 162 // Now send the appropriate FocusOut and FocusIn events. | 162 // Now send the appropriate FocusOut and FocusIn events. |
| 163 SendFocusEvents(xid, xid2); | 163 SendFocusEvents(xid, xid2); |
| 164 EXPECT_EQ(xid2, wm_->active_window_xid()); | 164 EXPECT_EQ(xid2, GetActiveWindowProperty()); |
| 165 EXPECT_TRUE(info->all_buttons_grabbed); | 165 EXPECT_TRUE(info->all_buttons_grabbed); |
| 166 EXPECT_FALSE(info2->all_buttons_grabbed); | 166 EXPECT_FALSE(info2->all_buttons_grabbed); |
| 167 | 167 |
| 168 // Now send a _NET_ACTIVE_WINDOW message asking the window manager to | 168 // Now send a _NET_ACTIVE_WINDOW message asking the window manager to |
| 169 // focus the first window. | 169 // focus the first window. |
| 170 MockXConnection::InitClientMessageEvent( | 170 MockXConnection::InitClientMessageEvent( |
| 171 &event, | 171 &event, |
| 172 xid, // window to focus | 172 xid, // window to focus |
| 173 wm_->GetXAtom(ATOM_NET_ACTIVE_WINDOW), | 173 wm_->GetXAtom(ATOM_NET_ACTIVE_WINDOW), |
| 174 1, // source indication: client app | 174 1, // source indication: client app |
| 175 CurrentTime, | 175 CurrentTime, |
| 176 xid2, // currently-active window | 176 xid2, // currently-active window |
| 177 None); | 177 None); |
| 178 EXPECT_TRUE(wm_->HandleEvent(&event)); | 178 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 179 EXPECT_EQ(xid, xconn_->focused_xid()); | 179 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 180 ASSERT_TRUE(lm_->active_toplevel_ != NULL); | 180 ASSERT_TRUE(lm_->active_toplevel_ != NULL); |
| 181 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); | 181 EXPECT_EQ(xid, lm_->active_toplevel_->win()->xid()); |
| 182 | 182 |
| 183 // Send the appropriate FocusOut and FocusIn events. | 183 // Send the appropriate FocusOut and FocusIn events. |
| 184 SendFocusEvents(xid2, xid); | 184 SendFocusEvents(xid2, xid); |
| 185 EXPECT_EQ(xid, wm_->active_window_xid()); | 185 EXPECT_EQ(xid, GetActiveWindowProperty()); |
| 186 EXPECT_FALSE(info->all_buttons_grabbed); | 186 EXPECT_FALSE(info->all_buttons_grabbed); |
| 187 EXPECT_TRUE(info2->all_buttons_grabbed); | 187 EXPECT_TRUE(info2->all_buttons_grabbed); |
| 188 | 188 |
| 189 // Unmap the first window and check that the second window gets focused. | 189 // Unmap the first window and check that the second window gets focused. |
| 190 MockXConnection::InitUnmapEvent(&event, xid); | 190 MockXConnection::InitUnmapEvent(&event, xid); |
| 191 EXPECT_TRUE(wm_->HandleEvent(&event)); | 191 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 192 EXPECT_EQ(xid2, xconn_->focused_xid()); | 192 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 193 ASSERT_TRUE(lm_->active_toplevel_ != NULL); | 193 ASSERT_TRUE(lm_->active_toplevel_ != NULL); |
| 194 EXPECT_EQ(xid2, lm_->active_toplevel_->win()->xid()); | 194 EXPECT_EQ(xid2, lm_->active_toplevel_->win()->xid()); |
| 195 | 195 |
| 196 SendFocusEvents(None, xid2); | 196 SendFocusEvents(None, xid2); |
| 197 EXPECT_EQ(xid2, wm_->active_window_xid()); | 197 EXPECT_EQ(xid2, GetActiveWindowProperty()); |
| 198 EXPECT_FALSE(info2->all_buttons_grabbed); | 198 EXPECT_FALSE(info2->all_buttons_grabbed); |
| 199 } | 199 } |
| 200 | 200 |
| 201 TEST_F(LayoutManagerTest, ConfigureTransient) { | 201 TEST_F(LayoutManagerTest, ConfigureTransient) { |
| 202 XEvent event; | 202 XEvent event; |
| 203 | 203 |
| 204 // Create and map a toplevel window. | 204 // Create and map a toplevel window. |
| 205 XWindow owner_xid = CreateSimpleWindow(); | 205 XWindow owner_xid = CreateSimpleWindow(); |
| 206 MockXConnection::WindowInfo* owner_info = | 206 MockXConnection::WindowInfo* owner_info = |
| 207 xconn_->GetWindowInfoOrDie(owner_xid); | 207 xconn_->GetWindowInfoOrDie(owner_xid); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 // Create a window. | 273 // Create a window. |
| 274 XWindow xid = CreateSimpleWindow(); | 274 XWindow xid = CreateSimpleWindow(); |
| 275 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 275 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 276 | 276 |
| 277 // Send CreateNotify, MapNotify, and FocusNotify events. | 277 // Send CreateNotify, MapNotify, and FocusNotify events. |
| 278 XEvent event; | 278 XEvent event; |
| 279 SendInitialEventsForWindow(xid); | 279 SendInitialEventsForWindow(xid); |
| 280 EXPECT_EQ(xid, xconn_->focused_xid()); | 280 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 281 SendFocusEvents(xconn_->GetRootWindow(), xid); | 281 SendFocusEvents(xconn_->GetRootWindow(), xid); |
| 282 EXPECT_FALSE(info->all_buttons_grabbed); | 282 EXPECT_FALSE(info->all_buttons_grabbed); |
| 283 EXPECT_EQ(xid, wm_->active_window_xid()); | 283 EXPECT_EQ(xid, GetActiveWindowProperty()); |
| 284 EXPECT_TRUE(wm_->GetWindow(xid)->focused()); | 284 EXPECT_TRUE(wm_->GetWindow(xid)->focused()); |
| 285 | 285 |
| 286 // Now create a transient window. | 286 // Now create a transient window. |
| 287 XWindow transient_xid = CreateSimpleWindow(); | 287 XWindow transient_xid = CreateSimpleWindow(); |
| 288 MockXConnection::WindowInfo* transient_info = | 288 MockXConnection::WindowInfo* transient_info = |
| 289 xconn_->GetWindowInfoOrDie(transient_xid); | 289 xconn_->GetWindowInfoOrDie(transient_xid); |
| 290 transient_info->transient_for = xid; | 290 transient_info->transient_for = xid; |
| 291 | 291 |
| 292 // Send CreateNotify and MapNotify events for the transient window. | 292 // Send CreateNotify and MapNotify events for the transient window. |
| 293 SendInitialEventsForWindow(transient_xid); | 293 SendInitialEventsForWindow(transient_xid); |
| 294 | 294 |
| 295 // We should ask the X server to focus the transient window as soon as it | 295 // We should ask the X server to focus the transient window as soon as it |
| 296 // gets mapped. | 296 // gets mapped. |
| 297 EXPECT_EQ(transient_xid, xconn_->focused_xid()); | 297 EXPECT_EQ(transient_xid, xconn_->focused_xid()); |
| 298 | 298 |
| 299 // Send FocusOut and FocusIn events and check that we add a passive | 299 // Send FocusOut and FocusIn events and check that we add a passive |
| 300 // button grab on the owner window and remove the grab on the transient. | 300 // button grab on the owner window and remove the grab on the transient. |
| 301 SendFocusEvents(xid, transient_xid); | 301 SendFocusEvents(xid, transient_xid); |
| 302 EXPECT_TRUE(info->all_buttons_grabbed); | 302 EXPECT_TRUE(info->all_buttons_grabbed); |
| 303 EXPECT_FALSE(transient_info->all_buttons_grabbed); | 303 EXPECT_FALSE(transient_info->all_buttons_grabbed); |
| 304 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 304 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 305 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); | 305 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); |
| 306 | 306 |
| 307 // _NET_ACTIVE_WINDOW should still be set to the owner instead of the | 307 // _NET_ACTIVE_WINDOW should also be set to the transient window (EWMH is |
| 308 // transient window, though. | 308 // vague about this, but it seems to match what other WMs do). |
| 309 EXPECT_EQ(xid, wm_->active_window_xid()); | 309 EXPECT_EQ(transient_xid, GetActiveWindowProperty()); |
| 310 | 310 |
| 311 // Now simulate a button press on the owner window. | 311 // Now simulate a button press on the owner window. |
| 312 xconn_->set_pointer_grab_xid(xid); | 312 xconn_->set_pointer_grab_xid(xid); |
| 313 MockXConnection::InitButtonPressEvent(&event, xid, 0, 0, 1); // x, y, button | 313 MockXConnection::InitButtonPressEvent(&event, xid, 0, 0, 1); // x, y, button |
| 314 EXPECT_TRUE(wm_->HandleEvent(&event)); | 314 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 315 | 315 |
| 316 // LayoutManager should remove the active pointer grab and try to focus | 316 // LayoutManager should remove the active pointer grab and try to focus |
| 317 // the owner window. | 317 // the owner window. |
| 318 EXPECT_EQ(None, xconn_->pointer_grab_xid()); | 318 EXPECT_EQ(None, xconn_->pointer_grab_xid()); |
| 319 EXPECT_EQ(xid, xconn_->focused_xid()); | 319 EXPECT_EQ(xid, xconn_->focused_xid()); |
| 320 | 320 |
| 321 // After the FocusOut and FocusIn events come through, the button grabs | 321 // After the FocusOut and FocusIn events come through, the button grabs |
| 322 // should be updated again. | 322 // should be updated again. |
| 323 SendFocusEvents(transient_xid, xid); | 323 SendFocusEvents(transient_xid, xid); |
| 324 EXPECT_FALSE(info->all_buttons_grabbed); | 324 EXPECT_FALSE(info->all_buttons_grabbed); |
| 325 EXPECT_TRUE(transient_info->all_buttons_grabbed); | 325 EXPECT_TRUE(transient_info->all_buttons_grabbed); |
| 326 EXPECT_EQ(xid, wm_->active_window_xid()); | 326 EXPECT_EQ(xid, GetActiveWindowProperty()); |
| 327 EXPECT_TRUE(wm_->GetWindow(xid)->focused()); | 327 EXPECT_TRUE(wm_->GetWindow(xid)->focused()); |
| 328 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); | 328 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); |
| 329 | 329 |
| 330 // Give the focus back to the transient window. | 330 // Give the focus back to the transient window. |
| 331 xconn_->set_pointer_grab_xid(transient_xid); | 331 xconn_->set_pointer_grab_xid(transient_xid); |
| 332 MockXConnection::InitButtonPressEvent(&event, transient_xid, 0, 0, 1); | 332 MockXConnection::InitButtonPressEvent(&event, transient_xid, 0, 0, 1); |
| 333 EXPECT_TRUE(wm_->HandleEvent(&event)); | 333 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 334 EXPECT_EQ(transient_xid, xconn_->focused_xid()); | 334 EXPECT_EQ(transient_xid, xconn_->focused_xid()); |
| 335 SendFocusEvents(xid, transient_xid); | 335 SendFocusEvents(xid, transient_xid); |
| 336 EXPECT_EQ(transient_xid, GetActiveWindowProperty()); |
| 336 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 337 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 337 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); | 338 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); |
| 338 | 339 |
| 339 // Set the transient window as modal. | 340 // Set the transient window as modal. |
| 340 MockXConnection::InitClientMessageEvent( | 341 MockXConnection::InitClientMessageEvent( |
| 341 &event, transient_xid, wm_->GetXAtom(ATOM_NET_WM_STATE), | 342 &event, transient_xid, wm_->GetXAtom(ATOM_NET_WM_STATE), |
| 342 1, wm_->GetXAtom(ATOM_NET_WM_STATE_MODAL), None, None); | 343 1, wm_->GetXAtom(ATOM_NET_WM_STATE_MODAL), None, None); |
| 343 EXPECT_TRUE(wm_->HandleEvent(&event)); | 344 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 344 | 345 |
| 345 // Since it's modal, the transient window should still keep the focus | 346 // Since it's modal, the transient window should still keep the focus |
| 346 // after a button press in the owner window. | 347 // after a button press in the owner window. |
| 347 xconn_->set_pointer_grab_xid(xid); | 348 xconn_->set_pointer_grab_xid(xid); |
| 348 MockXConnection::InitButtonPressEvent(&event, xid, 0, 0, 1); | 349 MockXConnection::InitButtonPressEvent(&event, xid, 0, 0, 1); |
| 349 EXPECT_TRUE(wm_->HandleEvent(&event)); | 350 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 350 EXPECT_EQ(transient_xid, xconn_->focused_xid()); | 351 EXPECT_EQ(transient_xid, xconn_->focused_xid()); |
| 352 EXPECT_EQ(transient_xid, GetActiveWindowProperty()); |
| 351 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 353 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 352 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); | 354 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); |
| 353 | 355 |
| 354 // Now create another top-level window, which we'll switch to | 356 // Now create another toplevel window, which we'll switch to |
| 355 // automatically. | 357 // automatically. |
| 356 XWindow xid2 = CreateSimpleWindow(); | 358 XWindow xid2 = CreateSimpleWindow(); |
| 357 MockXConnection::WindowInfo* info2 = xconn_->GetWindowInfoOrDie(xid2); | 359 MockXConnection::WindowInfo* info2 = xconn_->GetWindowInfoOrDie(xid2); |
| 358 SendInitialEventsForWindow(xid2); | 360 SendInitialEventsForWindow(xid2); |
| 359 EXPECT_EQ(xid2, xconn_->focused_xid()); | 361 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 360 SendFocusEvents(transient_xid, xid2); | 362 SendFocusEvents(transient_xid, xid2); |
| 361 EXPECT_EQ(xid2, wm_->active_window_xid()); | 363 EXPECT_EQ(xid2, GetActiveWindowProperty()); |
| 362 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 364 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 363 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); | 365 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); |
| 364 EXPECT_TRUE(wm_->GetWindow(xid2)->focused()); | 366 EXPECT_TRUE(wm_->GetWindow(xid2)->focused()); |
| 365 | 367 |
| 366 // When we cycle to the first toplevel window, its modal transient | 368 // When we cycle to the first toplevel window, its modal transient |
| 367 // window, rather than the toplevel itself, should get the focus. | 369 // window, rather than the toplevel itself, should get the focus. |
| 368 lm_->CycleActiveToplevelWindow(false); | 370 lm_->CycleActiveToplevelWindow(false); |
| 369 EXPECT_EQ(transient_xid, xconn_->focused_xid()); | 371 EXPECT_EQ(transient_xid, xconn_->focused_xid()); |
| 370 SendFocusEvents(xid2, transient_xid); | 372 SendFocusEvents(xid2, transient_xid); |
| 371 EXPECT_EQ(xid, wm_->active_window_xid()); | 373 EXPECT_EQ(transient_xid, GetActiveWindowProperty()); |
| 372 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 374 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 373 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); | 375 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); |
| 374 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); | 376 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); |
| 375 | 377 |
| 376 // Switch back to the second toplevel window. | 378 // Switch back to the second toplevel window. |
| 377 lm_->CycleActiveToplevelWindow(false); | 379 lm_->CycleActiveToplevelWindow(false); |
| 378 EXPECT_EQ(xid2, xconn_->focused_xid()); | 380 EXPECT_EQ(xid2, xconn_->focused_xid()); |
| 379 SendFocusEvents(transient_xid, xid2); | 381 SendFocusEvents(transient_xid, xid2); |
| 380 EXPECT_EQ(xid2, wm_->active_window_xid()); | 382 EXPECT_EQ(xid2, GetActiveWindowProperty()); |
| 381 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 383 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 382 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); | 384 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); |
| 383 EXPECT_TRUE(wm_->GetWindow(xid2)->focused()); | 385 EXPECT_TRUE(wm_->GetWindow(xid2)->focused()); |
| 384 | 386 |
| 385 // Make the transient window non-modal. | 387 // Make the transient window non-modal. |
| 386 MockXConnection::InitClientMessageEvent( | 388 MockXConnection::InitClientMessageEvent( |
| 387 &event, transient_xid, wm_->GetXAtom(ATOM_NET_WM_STATE), | 389 &event, transient_xid, wm_->GetXAtom(ATOM_NET_WM_STATE), |
| 388 0, wm_->GetXAtom(ATOM_NET_WM_STATE_MODAL), None, None); | 390 0, wm_->GetXAtom(ATOM_NET_WM_STATE_MODAL), None, None); |
| 389 EXPECT_TRUE(wm_->HandleEvent(&event)); | 391 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 390 | 392 |
| 391 // Now send a _NET_ACTIVE_WINDOW message asking to focus the transient. | 393 // Now send a _NET_ACTIVE_WINDOW message asking to focus the transient. |
| 392 // We should switch back to the first toplevel, and the transient should | 394 // We should switch back to the first toplevel, and the transient should |
| 393 // get the focus. | 395 // get the focus. |
| 394 MockXConnection::InitClientMessageEvent( | 396 MockXConnection::InitClientMessageEvent( |
| 395 &event, transient_xid, wm_->GetXAtom(ATOM_NET_ACTIVE_WINDOW), | 397 &event, transient_xid, wm_->GetXAtom(ATOM_NET_ACTIVE_WINDOW), |
| 396 1, 21321, 0, None); | 398 1, 21321, 0, None); |
| 397 EXPECT_TRUE(wm_->HandleEvent(&event)); | 399 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 398 EXPECT_EQ(transient_xid, xconn_->focused_xid()); | 400 EXPECT_EQ(transient_xid, xconn_->focused_xid()); |
| 399 MockXConnection::InitFocusOutEvent( | 401 MockXConnection::InitFocusOutEvent( |
| 400 &event, xid2, NotifyNormal, NotifyNonlinear); | 402 &event, xid2, NotifyNormal, NotifyNonlinear); |
| 401 EXPECT_TRUE(wm_->HandleEvent(&event)); | 403 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 402 MockXConnection::InitFocusInEvent( | 404 MockXConnection::InitFocusInEvent( |
| 403 &event, transient_xid, NotifyNormal, NotifyNonlinear); | 405 &event, transient_xid, NotifyNormal, NotifyNonlinear); |
| 404 EXPECT_TRUE(wm_->HandleEvent(&event)); | 406 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 405 EXPECT_EQ(xid, wm_->active_window_xid()); | 407 EXPECT_EQ(transient_xid, GetActiveWindowProperty()); |
| 406 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 408 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 407 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); | 409 EXPECT_TRUE(wm_->GetWindow(transient_xid)->focused()); |
| 408 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); | 410 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); |
| 409 | 411 |
| 410 // Switch to overview mode. We should give the focus back to the root | 412 // Switch to overview mode. We should give the focus back to the root |
| 411 // window (we don't want the transient to receive keypresses at this | 413 // window (we don't want the transient to receive keypresses at this |
| 412 // point). | 414 // point). |
| 413 lm_->SetMode(LayoutManager::MODE_OVERVIEW); | 415 lm_->SetMode(LayoutManager::MODE_OVERVIEW); |
| 414 EXPECT_EQ(xconn_->GetRootWindow(), xconn_->focused_xid()); | 416 EXPECT_EQ(xconn_->GetRootWindow(), xconn_->focused_xid()); |
| 415 MockXConnection::InitFocusOutEvent( | 417 MockXConnection::InitFocusOutEvent( |
| 416 &event, transient_xid, NotifyWhileGrabbed, NotifyNonlinear); | 418 &event, transient_xid, NotifyWhileGrabbed, NotifyNonlinear); |
| 417 EXPECT_TRUE(wm_->HandleEvent(&event)); | 419 EXPECT_TRUE(wm_->HandleEvent(&event)); |
| 418 MockXConnection::InitFocusInEvent( | 420 MockXConnection::InitFocusInEvent( |
| 419 &event, transient_xid, NotifyWhileGrabbed, NotifyPointer); | 421 &event, transient_xid, NotifyWhileGrabbed, NotifyPointer); |
| 420 EXPECT_FALSE(wm_->HandleEvent(&event)); | 422 EXPECT_FALSE(wm_->HandleEvent(&event)); |
| 421 EXPECT_EQ(None, wm_->active_window_xid()); | 423 EXPECT_EQ(None, GetActiveWindowProperty()); |
| 422 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); | 424 EXPECT_FALSE(wm_->GetWindow(xid)->focused()); |
| 423 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); | 425 EXPECT_FALSE(wm_->GetWindow(transient_xid)->focused()); |
| 424 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); | 426 EXPECT_FALSE(wm_->GetWindow(xid2)->focused()); |
| 425 } | 427 } |
| 426 | 428 |
| 427 TEST_F(LayoutManagerTest, MultipleTransients) { | 429 TEST_F(LayoutManagerTest, MultipleTransients) { |
| 428 // Create a window. | 430 // Create a window. |
| 429 XWindow owner_xid = CreateSimpleWindow(); | 431 XWindow owner_xid = CreateSimpleWindow(); |
| 430 MockXConnection::WindowInfo* owner_info = | 432 MockXConnection::WindowInfo* owner_info = |
| 431 xconn_->GetWindowInfoOrDie(owner_xid); | 433 xconn_->GetWindowInfoOrDie(owner_xid); |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 stage->GetStackingIndex(win->actor())); | 724 stage->GetStackingIndex(win->actor())); |
| 723 EXPECT_LT(stage->GetStackingIndex(win->actor()), | 725 EXPECT_LT(stage->GetStackingIndex(win->actor()), |
| 724 stage->GetStackingIndex(lower_stacking_actor)); | 726 stage->GetStackingIndex(lower_stacking_actor)); |
| 725 } | 727 } |
| 726 | 728 |
| 727 } // namespace chromeos | 729 } // namespace chromeos |
| 728 | 730 |
| 729 int main(int argc, char **argv) { | 731 int main(int argc, char **argv) { |
| 730 return chromeos::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 732 return chromeos::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 731 } | 733 } |
| OLD | NEW |