| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium 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 "ui/aura/desktop_host.h" | 5 #include "ui/aura/desktop_host.h" |
| 6 | 6 |
| 7 #include <X11/cursorfont.h> | 7 #include <X11/cursorfont.h> |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 desktop_ = desktop; | 370 desktop_ = desktop; |
| 371 } | 371 } |
| 372 | 372 |
| 373 gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() { | 373 gfx::AcceleratedWidget DesktopHostLinux::GetAcceleratedWidget() { |
| 374 return xwindow_; | 374 return xwindow_; |
| 375 } | 375 } |
| 376 | 376 |
| 377 void DesktopHostLinux::Show() { | 377 void DesktopHostLinux::Show() { |
| 378 XMapWindow(xdisplay_, xwindow_); | 378 XMapWindow(xdisplay_, xwindow_); |
| 379 | 379 |
| 380 // Wait for notification that the window is mapped, which happens |
| 381 // asynchronously if there's a window manager running. Ideally we wouldn't |
| 382 // need to wait for this, but some window managers don't do anything to let us |
| 383 // know that they're there (*cough*ion3*cough*), in which case we need to make |
| 384 // sure that the window is mapped before sending a SetInputFocus request. |
| 385 while (true) { |
| 386 XEvent event; |
| 387 XWindowEvent(xdisplay_, xwindow_, StructureNotifyMask, &event); |
| 388 if (event.type == MapNotify) |
| 389 break; |
| 390 } |
| 391 |
| 380 // If there's no window manager running, we need to assign the X input focus | 392 // If there's no window manager running, we need to assign the X input focus |
| 381 // to our host window. (If there's no window manager running, it should also | 393 // to our host window. |
| 382 // be safe to assume that the host window will have been mapped by the time | 394 if (!IsWindowManagerPresent()) { |
| 383 // that our SetInputFocus request is received.) | |
| 384 if (!IsWindowManagerPresent()) | |
| 385 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); | 395 XSetInputFocus(xdisplay_, xwindow_, RevertToNone, CurrentTime); |
| 386 | 396 XFlush(xdisplay_); |
| 387 XFlush(xdisplay_); | 397 } |
| 388 } | 398 } |
| 389 | 399 |
| 390 gfx::Size DesktopHostLinux::GetSize() const { | 400 gfx::Size DesktopHostLinux::GetSize() const { |
| 391 return bounds_.size(); | 401 return bounds_.size(); |
| 392 } | 402 } |
| 393 | 403 |
| 394 void DesktopHostLinux::SetSize(const gfx::Size& size) { | 404 void DesktopHostLinux::SetSize(const gfx::Size& size) { |
| 395 if (bounds_.size() == size) | 405 if (bounds_.size() == size) |
| 396 return; | 406 return; |
| 397 bounds_.set_size(size); | 407 bounds_.set_size(size); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 443 } |
| 434 | 444 |
| 435 } // namespace | 445 } // namespace |
| 436 | 446 |
| 437 // static | 447 // static |
| 438 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { | 448 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { |
| 439 return new DesktopHostLinux(bounds); | 449 return new DesktopHostLinux(bounds); |
| 440 } | 450 } |
| 441 | 451 |
| 442 } // namespace aura | 452 } // namespace aura |
| OLD | NEW |