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/aura/root_window_host_x11.h" | 5 #include "ui/aura/root_window_host_x11.h" |
6 | 6 |
7 #include <strings.h> | 7 #include <strings.h> |
8 #include <X11/cursorfont.h> | 8 #include <X11/cursorfont.h> |
9 #include <X11/extensions/Xfixes.h> | 9 #include <X11/extensions/Xfixes.h> |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 ui::SetIntProperty(xwindow_, | 815 ui::SetIntProperty(xwindow_, |
816 k_NET_WM_USER_TIME, | 816 k_NET_WM_USER_TIME, |
817 k_NET_WM_USER_TIME, | 817 k_NET_WM_USER_TIME, |
818 0); | 818 0); |
819 } | 819 } |
820 } | 820 } |
821 | 821 |
822 bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, | 822 bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, |
823 const gfx::Point& dest_offset, | 823 const gfx::Point& dest_offset, |
824 SkCanvas* canvas) { | 824 SkCanvas* canvas) { |
825 scoped_ptr<ui::XScopedImage> scoped_image(GetXImage(source_bounds)); | 825 ui::XScopedImage scoped_image( |
826 if (!scoped_image) | 826 XGetImage(xdisplay_, xwindow_, |
| 827 source_bounds.x(), source_bounds.y(), |
| 828 source_bounds.width(), source_bounds.height(), |
| 829 AllPlanes, ZPixmap)); |
| 830 XImage* image = scoped_image.get(); |
| 831 if (!image) { |
| 832 LOG(ERROR) << "XGetImage failed"; |
827 return false; | 833 return false; |
828 | 834 } |
829 XImage* image = scoped_image->get(); | |
830 DCHECK(image); | |
831 | 835 |
832 if (image->bits_per_pixel == 32) { | 836 if (image->bits_per_pixel == 32) { |
833 if ((0xff << SK_R32_SHIFT) != image->red_mask || | 837 if ((0xff << SK_R32_SHIFT) != image->red_mask || |
834 (0xff << SK_G32_SHIFT) != image->green_mask || | 838 (0xff << SK_G32_SHIFT) != image->green_mask || |
835 (0xff << SK_B32_SHIFT) != image->blue_mask) { | 839 (0xff << SK_B32_SHIFT) != image->blue_mask) { |
836 LOG(WARNING) << "XImage and Skia byte orders differ"; | 840 LOG(WARNING) << "XImage and Skia byte orders differ"; |
837 return false; | 841 return false; |
838 } | 842 } |
839 | 843 |
840 // Set the alpha channel before copying to the canvas. Otherwise, areas of | 844 // Set the alpha channel before copying to the canvas. Otherwise, areas of |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 // host window, then convert it back to this host window's coordinate. | 1082 // host window, then convert it back to this host window's coordinate. |
1079 screen_position_client->ConvertHostPointToScreen(root_window, &location); | 1083 screen_position_client->ConvertHostPointToScreen(root_window, &location); |
1080 screen_position_client->ConvertPointFromScreen(root_window, &location); | 1084 screen_position_client->ConvertPointFromScreen(root_window, &location); |
1081 root_window->ConvertPointToHost(&location); | 1085 root_window->ConvertPointToHost(&location); |
1082 event->set_location(location); | 1086 event->set_location(location); |
1083 event->set_root_location(location); | 1087 event->set_root_location(location); |
1084 } | 1088 } |
1085 delegate_->OnHostMouseEvent(event); | 1089 delegate_->OnHostMouseEvent(event); |
1086 } | 1090 } |
1087 | 1091 |
1088 scoped_ptr<ui::XScopedImage> RootWindowHostX11::GetXImage( | |
1089 const gfx::Rect& snapshot_bounds) { | |
1090 scoped_ptr<ui::XScopedImage> image(new ui::XScopedImage( | |
1091 XGetImage(xdisplay_, xwindow_, | |
1092 snapshot_bounds.x(), snapshot_bounds.y(), | |
1093 snapshot_bounds.width(), snapshot_bounds.height(), | |
1094 AllPlanes, ZPixmap))); | |
1095 if (!image) { | |
1096 LOG(ERROR) << "XGetImage failed"; | |
1097 image.reset(); | |
1098 } | |
1099 return image.Pass(); | |
1100 } | |
1101 | |
1102 void RootWindowHostX11::UpdateIsInternalDisplay() { | 1092 void RootWindowHostX11::UpdateIsInternalDisplay() { |
1103 RootWindow* root_window = GetRootWindow(); | 1093 RootWindow* root_window = GetRootWindow(); |
1104 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); | 1094 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); |
1105 gfx::Display display = screen->GetDisplayNearestWindow(root_window); | 1095 gfx::Display display = screen->GetDisplayNearestWindow(root_window); |
1106 is_internal_display_ = display.IsInternal(); | 1096 is_internal_display_ = display.IsInternal(); |
1107 } | 1097 } |
1108 | 1098 |
1109 void RootWindowHostX11::SetCrOSTapPaused(bool state) { | 1099 void RootWindowHostX11::SetCrOSTapPaused(bool state) { |
1110 #if defined(OS_CHROMEOS) | 1100 #if defined(OS_CHROMEOS) |
1111 // Temporarily pause tap-to-click when the cursor is hidden. | 1101 // Temporarily pause tap-to-click when the cursor is hidden. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 } | 1136 } |
1147 | 1137 |
1148 namespace test { | 1138 namespace test { |
1149 | 1139 |
1150 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 1140 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
1151 default_override_redirect = override_redirect; | 1141 default_override_redirect = override_redirect; |
1152 } | 1142 } |
1153 | 1143 |
1154 } // namespace test | 1144 } // namespace test |
1155 } // namespace aura | 1145 } // namespace aura |
OLD | NEW |