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_linux.h" | 5 #include "ui/aura/root_window_host_linux.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 #include <X11/Xcursor/Xcursor.h> | 8 #include <X11/Xcursor/Xcursor.h> |
9 #include <X11/Xlib.h> | |
9 #include <X11/cursorfont.h> | 10 #include <X11/cursorfont.h> |
10 #include <X11/extensions/XInput2.h> | 11 #include <X11/extensions/XInput2.h> |
11 #include <X11/extensions/Xfixes.h> | 12 #include <X11/extensions/Xfixes.h> |
12 #include <X11/extensions/Xrandr.h> | 13 #include <X11/extensions/Xrandr.h> |
13 #include <algorithm> | 14 #include <algorithm> |
14 | 15 |
15 #include "base/message_pump_x.h" | 16 #include "base/message_pump_x.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
18 #include "grit/ui_resources_standard.h" | 19 #include "grit/ui_resources_standard.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "ui/aura/client/user_gesture_client.h" | 21 #include "ui/aura/client/user_gesture_client.h" |
21 #include "ui/aura/dispatcher_linux.h" | 22 #include "ui/aura/dispatcher_linux.h" |
22 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
23 #include "ui/aura/event.h" | 24 #include "ui/aura/event.h" |
24 #include "ui/aura/root_window.h" | 25 #include "ui/aura/root_window.h" |
25 #include "ui/base/cursor/cursor.h" | 26 #include "ui/base/cursor/cursor.h" |
26 #include "ui/base/keycodes/keyboard_codes.h" | 27 #include "ui/base/keycodes/keyboard_codes.h" |
27 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
28 #include "ui/base/touch/touch_factory.h" | 29 #include "ui/base/touch/touch_factory.h" |
29 #include "ui/base/view_prop.h" | 30 #include "ui/base/view_prop.h" |
30 #include "ui/base/x/x11_util.h" | 31 #include "ui/base/x/x11_util.h" |
31 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
33 #include "ui/gfx/codec/png_codec.h" | |
32 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
33 | 35 |
34 using std::max; | 36 using std::max; |
35 using std::min; | 37 using std::min; |
36 | 38 |
37 namespace aura { | 39 namespace aura { |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 // Standard Linux mouse buttons for going back and forward. | 43 // Standard Linux mouse buttons for going back and forward. |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
797 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME"; | 799 static const char* k_NET_WM_USER_TIME = "_NET_WM_USER_TIME"; |
798 focus_when_shown_ = focus_when_shown; | 800 focus_when_shown_ = focus_when_shown; |
799 if (IsWindowManagerPresent() && !focus_when_shown_) { | 801 if (IsWindowManagerPresent() && !focus_when_shown_) { |
800 ui::SetIntProperty(xwindow_, | 802 ui::SetIntProperty(xwindow_, |
801 k_NET_WM_USER_TIME, | 803 k_NET_WM_USER_TIME, |
802 k_NET_WM_USER_TIME, | 804 k_NET_WM_USER_TIME, |
803 0); | 805 0); |
804 } | 806 } |
805 } | 807 } |
806 | 808 |
809 bool RootWindowHostLinux::GrabWindowSnapshot( | |
810 std::vector<unsigned char>* png_representation, | |
811 const gfx::Rect& snapshot_bounds) { | |
812 XImage* image = XGetImage( | |
813 xdisplay_, xwindow_, | |
814 snapshot_bounds.x(), snapshot_bounds.y(), | |
815 snapshot_bounds.width(), snapshot_bounds.height(), | |
816 AllPlanes, ZPixmap); | |
817 | |
818 unsigned char* data = reinterpret_cast<unsigned char*>(image->data); | |
819 gfx::PNGCodec::Encode(data, gfx::PNGCodec::FORMAT_BGRA, | |
Daniel Erat
2012/05/14 23:17:40
I don't love the inflexibility of doing PNG encodi
Jun Mukai
2012/05/15 22:39:24
That's why original browser::GrabWindowSnapshot re
| |
820 snapshot_bounds.size(), | |
821 image->width * image->bits_per_pixel / 8, | |
822 true, std::vector<gfx::PNGCodec::Comment>(), | |
823 png_representation); | |
824 XFree(image); | |
825 return true; | |
826 } | |
827 | |
807 void RootWindowHostLinux::PostNativeEvent( | 828 void RootWindowHostLinux::PostNativeEvent( |
808 const base::NativeEvent& native_event) { | 829 const base::NativeEvent& native_event) { |
809 DCHECK(xwindow_); | 830 DCHECK(xwindow_); |
810 DCHECK(xdisplay_); | 831 DCHECK(xdisplay_); |
811 XEvent xevent = *native_event; | 832 XEvent xevent = *native_event; |
812 xevent.xany.display = xdisplay_; | 833 xevent.xany.display = xdisplay_; |
813 xevent.xany.window = xwindow_; | 834 xevent.xany.window = xwindow_; |
814 | 835 |
815 switch (xevent.type) { | 836 switch (xevent.type) { |
816 case EnterNotify: | 837 case EnterNotify: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); | 888 ui::ViewProp::GetValue(accelerated_widget, kRootWindowHostLinuxKey)); |
868 } | 889 } |
869 | 890 |
870 // static | 891 // static |
871 gfx::Size RootWindowHost::GetNativeScreenSize() { | 892 gfx::Size RootWindowHost::GetNativeScreenSize() { |
872 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); | 893 ::Display* xdisplay = base::MessagePumpX::GetDefaultXDisplay(); |
873 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); | 894 return gfx::Size(DisplayWidth(xdisplay, 0), DisplayHeight(xdisplay, 0)); |
874 } | 895 } |
875 | 896 |
876 } // namespace aura | 897 } // namespace aura |
OLD | NEW |