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 Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | |
sadrul
2011/11/18 21:46:54
Is there a reason to not use xdisplay_?
| |
488 DCHECK(xdisplay); | |
489 XEvent xevent = *native_event; | |
490 xevent.xany.display = xdisplay; | |
491 xevent.xany.window = xwindow_; | |
492 ::XPutBackEvent(xdisplay, &xevent); | |
493 } | |
494 | |
484 bool DesktopHostLinux::IsWindowManagerPresent() { | 495 bool DesktopHostLinux::IsWindowManagerPresent() { |
485 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership | 496 // Per ICCCM 2.8, "Manager Selections", window managers should take ownership |
486 // of WM_Sn selections (where n is a screen number). | 497 // of WM_Sn selections (where n is a screen number). |
487 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); | 498 ::Atom wm_s0_atom = XInternAtom(xdisplay_, "WM_S0", False); |
488 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; | 499 return XGetSelectionOwner(xdisplay_, wm_s0_atom) != None; |
489 } | 500 } |
490 | 501 |
491 } // namespace | 502 } // namespace |
492 | 503 |
493 // static | 504 // static |
494 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { | 505 DesktopHost* DesktopHost::Create(const gfx::Rect& bounds) { |
495 return new DesktopHostLinux(bounds); | 506 return new DesktopHostLinux(bounds); |
496 } | 507 } |
497 | 508 |
498 // static | 509 // static |
499 gfx::Size DesktopHost::GetNativeDisplaySize() { | 510 gfx::Size DesktopHost::GetNativeDisplaySize() { |
500 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | 511 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); |
501 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 512 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
502 } | 513 } |
503 | 514 |
504 } // namespace aura | 515 } // namespace aura |
OLD | NEW |