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 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 ui::SetIntProperty(xwindow_, | 785 ui::SetIntProperty(xwindow_, |
786 k_NET_WM_USER_TIME, | 786 k_NET_WM_USER_TIME, |
787 k_NET_WM_USER_TIME, | 787 k_NET_WM_USER_TIME, |
788 0); | 788 0); |
789 } | 789 } |
790 } | 790 } |
791 | 791 |
792 bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, | 792 bool RootWindowHostX11::CopyAreaToSkCanvas(const gfx::Rect& source_bounds, |
793 const gfx::Point& dest_offset, | 793 const gfx::Point& dest_offset, |
794 SkCanvas* canvas) { | 794 SkCanvas* canvas) { |
795 scoped_ptr<ui::XScopedImage> scoped_image(GetXImage(source_bounds)); | 795 ui::XScopedImage scoped_image( |
796 if (!scoped_image) | 796 XGetImage(xdisplay_, xwindow_, |
| 797 source_bounds.x(), source_bounds.y(), |
| 798 source_bounds.width(), source_bounds.height(), |
| 799 AllPlanes, ZPixmap)); |
| 800 XImage* image = scoped_image.get(); |
| 801 if (!image) { |
| 802 LOG(ERROR) << "XGetImage failed"; |
797 return false; | 803 return false; |
798 | 804 } |
799 XImage* image = scoped_image->get(); | |
800 DCHECK(image); | |
801 | 805 |
802 if (image->bits_per_pixel == 32) { | 806 if (image->bits_per_pixel == 32) { |
803 if ((0xff << SK_R32_SHIFT) != image->red_mask || | 807 if ((0xff << SK_R32_SHIFT) != image->red_mask || |
804 (0xff << SK_G32_SHIFT) != image->green_mask || | 808 (0xff << SK_G32_SHIFT) != image->green_mask || |
805 (0xff << SK_B32_SHIFT) != image->blue_mask) { | 809 (0xff << SK_B32_SHIFT) != image->blue_mask) { |
806 LOG(WARNING) << "XImage and Skia byte orders differ"; | 810 LOG(WARNING) << "XImage and Skia byte orders differ"; |
807 return false; | 811 return false; |
808 } | 812 } |
809 | 813 |
810 // Set the alpha channel before copying to the canvas. Otherwise, areas of | 814 // Set the alpha channel before copying to the canvas. Otherwise, areas of |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 // host window, then convert it back to this host window's coordinate. | 1044 // host window, then convert it back to this host window's coordinate. |
1041 screen_position_client->ConvertHostPointToScreen(root_window, &location); | 1045 screen_position_client->ConvertHostPointToScreen(root_window, &location); |
1042 screen_position_client->ConvertPointFromScreen(root_window, &location); | 1046 screen_position_client->ConvertPointFromScreen(root_window, &location); |
1043 root_window->ConvertPointToHost(&location); | 1047 root_window->ConvertPointToHost(&location); |
1044 event->set_location(location); | 1048 event->set_location(location); |
1045 event->set_root_location(location); | 1049 event->set_root_location(location); |
1046 } | 1050 } |
1047 delegate_->OnHostMouseEvent(event); | 1051 delegate_->OnHostMouseEvent(event); |
1048 } | 1052 } |
1049 | 1053 |
1050 scoped_ptr<ui::XScopedImage> RootWindowHostX11::GetXImage( | |
1051 const gfx::Rect& snapshot_bounds) { | |
1052 scoped_ptr<ui::XScopedImage> image(new ui::XScopedImage( | |
1053 XGetImage(xdisplay_, xwindow_, | |
1054 snapshot_bounds.x(), snapshot_bounds.y(), | |
1055 snapshot_bounds.width(), snapshot_bounds.height(), | |
1056 AllPlanes, ZPixmap))); | |
1057 if (!image) { | |
1058 LOG(ERROR) << "XGetImage failed"; | |
1059 image.reset(); | |
1060 } | |
1061 return image.Pass(); | |
1062 } | |
1063 | |
1064 void RootWindowHostX11::UpdateIsInternalDisplay() { | 1054 void RootWindowHostX11::UpdateIsInternalDisplay() { |
1065 RootWindow* root_window = GetRootWindow(); | 1055 RootWindow* root_window = GetRootWindow(); |
1066 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); | 1056 gfx::Screen* screen = gfx::Screen::GetScreenFor(root_window); |
1067 gfx::Display display = screen->GetDisplayNearestWindow(root_window); | 1057 gfx::Display display = screen->GetDisplayNearestWindow(root_window); |
1068 is_internal_display_ = display.IsInternal(); | 1058 is_internal_display_ = display.IsInternal(); |
1069 } | 1059 } |
1070 | 1060 |
1071 void RootWindowHostX11::SetCrOSTapPaused(bool state) { | 1061 void RootWindowHostX11::SetCrOSTapPaused(bool state) { |
1072 #if defined(OS_CHROMEOS) | 1062 #if defined(OS_CHROMEOS) |
1073 // Temporarily pause tap-to-click when the cursor is hidden. | 1063 // Temporarily pause tap-to-click when the cursor is hidden. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 } | 1098 } |
1109 | 1099 |
1110 namespace test { | 1100 namespace test { |
1111 | 1101 |
1112 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { | 1102 void SetUseOverrideRedirectWindowByDefault(bool override_redirect) { |
1113 default_override_redirect = override_redirect; | 1103 default_override_redirect = override_redirect; |
1114 } | 1104 } |
1115 | 1105 |
1116 } // namespace test | 1106 } // namespace test |
1117 } // namespace aura | 1107 } // namespace aura |
OLD | NEW |