| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/widget/desktop_aura/desktop_root_window_host_linux.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_linux.h" |
| 6 | 6 |
| 7 #include <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
| 8 #include <X11/Xatom.h> | 8 #include <X11/Xatom.h> |
| 9 #include <X11/Xutil.h> | 9 #include <X11/Xutil.h> |
| 10 | 10 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 return gfx::Rect(); | 444 return gfx::Rect(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 gfx::Rect DesktopRootWindowHostLinux::GetWorkAreaBoundsInScreen() const { | 447 gfx::Rect DesktopRootWindowHostLinux::GetWorkAreaBoundsInScreen() const { |
| 448 std::vector<int> value; | 448 std::vector<int> value; |
| 449 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) && | 449 if (ui::GetIntArrayProperty(x_root_window_, "_NET_WORKAREA", &value) && |
| 450 value.size() >= 4) { | 450 value.size() >= 4) { |
| 451 return gfx::Rect(value[0], value[1], value[2], value[3]); | 451 return gfx::Rect(value[0], value[1], value[2], value[3]); |
| 452 } | 452 } |
| 453 | 453 |
| 454 // TODO(erg): As a fallback, we should return the bounds for the current | 454 // Fetch the geometry of the root window. |
| 455 // monitor. However, that's pretty difficult and requires futzing with XRR. | 455 Window root; |
| 456 NOTIMPLEMENTED(); | 456 int x, y; |
| 457 return gfx::Rect(); | 457 unsigned int width, height; |
| 458 unsigned int border_width, depth; |
| 459 if (!XGetGeometry(xdisplay_, x_root_window_, &root, &x, &y, |
| 460 &width, &height, &border_width, &depth)) { |
| 461 NOTIMPLEMENTED(); |
| 462 return gfx::Rect(0, 0, 10, 10); |
| 463 } |
| 464 |
| 465 return gfx::Rect(x, y, width, height); |
| 458 } | 466 } |
| 459 | 467 |
| 460 void DesktopRootWindowHostLinux::SetShape(gfx::NativeRegion native_region) { | 468 void DesktopRootWindowHostLinux::SetShape(gfx::NativeRegion native_region) { |
| 461 // TODO(erg): | 469 // TODO(erg): |
| 462 NOTIMPLEMENTED(); | 470 NOTIMPLEMENTED(); |
| 463 } | 471 } |
| 464 | 472 |
| 465 void DesktopRootWindowHostLinux::Activate() { | 473 void DesktopRootWindowHostLinux::Activate() { |
| 466 X11DesktopHandler::get()->ActivateWindow(xwindow_); | 474 X11DesktopHandler::get()->ActivateWindow(xwindow_); |
| 467 } | 475 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 return bounds_; | 693 return bounds_; |
| 686 } | 694 } |
| 687 | 695 |
| 688 void DesktopRootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { | 696 void DesktopRootWindowHostLinux::SetBounds(const gfx::Rect& bounds) { |
| 689 bool origin_changed = bounds_.origin() != bounds.origin(); | 697 bool origin_changed = bounds_.origin() != bounds.origin(); |
| 690 bool size_changed = bounds_.size() != bounds.size(); | 698 bool size_changed = bounds_.size() != bounds.size(); |
| 691 XWindowChanges changes = {0}; | 699 XWindowChanges changes = {0}; |
| 692 unsigned value_mask = 0; | 700 unsigned value_mask = 0; |
| 693 | 701 |
| 694 if (size_changed) { | 702 if (size_changed) { |
| 703 // X11 will send an XError at our process if have a 0 sized window. |
| 704 DCHECK_GT(bounds.width(), 0); |
| 705 DCHECK_GT(bounds.height(), 0); |
| 706 |
| 695 changes.width = bounds.width(); | 707 changes.width = bounds.width(); |
| 696 changes.height = bounds.height(); | 708 changes.height = bounds.height(); |
| 697 value_mask |= CWHeight | CWWidth; | 709 value_mask |= CWHeight | CWWidth; |
| 698 } | 710 } |
| 699 | 711 |
| 700 if (origin_changed) { | 712 if (origin_changed) { |
| 701 changes.x = bounds.x(); | 713 changes.x = bounds.x(); |
| 702 changes.y = bounds.y(); | 714 changes.y = bounds.y(); |
| 703 value_mask |= CWX | CWY; | 715 value_mask |= CWX | CWY; |
| 704 } | 716 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 1113 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
| 1102 internal::NativeWidgetDelegate* native_widget_delegate, | 1114 internal::NativeWidgetDelegate* native_widget_delegate, |
| 1103 DesktopNativeWidgetAura* desktop_native_widget_aura, | 1115 DesktopNativeWidgetAura* desktop_native_widget_aura, |
| 1104 const gfx::Rect& initial_bounds) { | 1116 const gfx::Rect& initial_bounds) { |
| 1105 return new DesktopRootWindowHostLinux(native_widget_delegate, | 1117 return new DesktopRootWindowHostLinux(native_widget_delegate, |
| 1106 desktop_native_widget_aura, | 1118 desktop_native_widget_aura, |
| 1107 initial_bounds); | 1119 initial_bounds); |
| 1108 } | 1120 } |
| 1109 | 1121 |
| 1110 } // namespace views | 1122 } // namespace views |
| OLD | NEW |