| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 // DesktopHost Overrides. | 234 // DesktopHost Overrides. |
| 235 virtual void SetDesktop(Desktop* desktop) OVERRIDE; | 235 virtual void SetDesktop(Desktop* desktop) OVERRIDE; |
| 236 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 236 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
| 237 virtual void Show() OVERRIDE; | 237 virtual void Show() OVERRIDE; |
| 238 virtual void ToggleFullScreen() OVERRIDE; | 238 virtual void ToggleFullScreen() OVERRIDE; |
| 239 virtual gfx::Size GetSize() const OVERRIDE; | 239 virtual gfx::Size GetSize() const OVERRIDE; |
| 240 virtual void SetSize(const gfx::Size& size) OVERRIDE; | 240 virtual void SetSize(const gfx::Size& size) OVERRIDE; |
| 241 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; | 241 virtual void SetCursor(gfx::NativeCursor cursor_type) OVERRIDE; |
| 242 virtual gfx::Point QueryMouseLocation() OVERRIDE; | 242 virtual gfx::Point QueryMouseLocation() OVERRIDE; |
| 243 virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; |
| 243 | 244 |
| 244 // Returns true if there's an X window manager present... in most cases. Some | 245 // Returns true if there's an X window manager present... in most cases. Some |
| 245 // window managers (notably, ion3) don't implement enough of ICCCM for us to | 246 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
| 246 // detect that they're there. | 247 // detect that they're there. |
| 247 bool IsWindowManagerPresent(); | 248 bool IsWindowManagerPresent(); |
| 248 | 249 |
| 249 Desktop* desktop_; | 250 Desktop* desktop_; |
| 250 | 251 |
| 251 // The display and the native X window hosting the desktop. | 252 // The display and the native X window hosting the desktop. |
| 252 Display* xdisplay_; | 253 Display* xdisplay_; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 xwindow_, | 475 xwindow_, |
| 475 &root_return, | 476 &root_return, |
| 476 &child_return, | 477 &child_return, |
| 477 &root_x_return, &root_y_return, | 478 &root_x_return, &root_y_return, |
| 478 &win_x_return, &win_y_return, | 479 &win_x_return, &win_y_return, |
| 479 &mask_return); | 480 &mask_return); |
| 480 return gfx::Point(max(0, min(size_.width(), win_x_return)), | 481 return gfx::Point(max(0, min(size_.width(), win_x_return)), |
| 481 max(0, min(size_.height(), win_y_return))); | 482 max(0, min(size_.height(), win_y_return))); |
| 482 } | 483 } |
| 483 | 484 |
| 485 void DesktopHostLinux::PostNativeEvent(const base::NativeEvent& native_event) { |
| 486 DCHECK(xwindow_); |
| 487 DCHECK(xdisplay_); |
| 488 XEvent xevent = *native_event; |
| 489 xevent.xany.display = xdisplay_; |
| 490 xevent.xany.window = xwindow_; |
| 491 ::XPutBackEvent(xdisplay_, &xevent); |
| 492 } |
| 493 |
| 484 bool DesktopHostLinux::IsWindowManagerPresent() { | 494 bool DesktopHostLinux::IsWindowManagerPresent() { |
| 485 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership | 495 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
| 486 // of WM_Sn selections (where n is a screen number). | 496 // of WM_Sn selections (where n is a screen number). |
| 487 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); | 497 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); |
| 488 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; | 498 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; |
| 489 } | 499 } |
| 490 | 500 |
| 491 } // namespace | 501 } // namespace |
| 492 | 502 |
| 493 // static | 503 // static |
| 494 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { | 504 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { |
| 495 return new DesktopHostLinux(bounds); | 505 return new DesktopHostLinux(bounds); |
| 496 } | 506 } |
| 497 | 507 |
| 498 // static | 508 // static |
| 499 gfx::Size DesktopHost::GetNativeDisplaySize() { | 509 gfx::Size DesktopHost::GetNativeDisplaySize() { |
| 500 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | 510 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); |
| 501 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 511 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
| 502 } | 512 } |
| 503 | 513 |
| 504 } // namespace aura | 514 } // namespace aura |
| OLD | NEW |