| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater_auralinux.h
" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 | |
| 9 #include "base/macros.h" | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 #include "ui/aura/window_event_dispatcher.h" | |
| 12 #include "ui/base/cursor/cursor_loader.h" | |
| 13 #include "ui/base/cursor/cursors_aura.h" | |
| 14 #include "ui/display/display.h" | |
| 15 | |
| 16 namespace views { | |
| 17 namespace { | |
| 18 | |
| 19 // Cursors that we need to supply our own image resources for. This was | |
| 20 // generated from webcursor_gtk.cc; any cursor that either was NOTIMPLEMENTED() | |
| 21 // or already was implemented with a pixmap is on this list. | |
| 22 const int kImageCursorIds[] = { | |
| 23 ui::kCursorNorthEastSouthWestResize, | |
| 24 ui::kCursorNorthWestSouthEastResize, | |
| 25 ui::kCursorVerticalText, | |
| 26 ui::kCursorCell, | |
| 27 ui::kCursorContextMenu, | |
| 28 ui::kCursorAlias, | |
| 29 ui::kCursorNoDrop, | |
| 30 ui::kCursorCopy, | |
| 31 ui::kCursorNotAllowed, | |
| 32 ui::kCursorZoomIn, | |
| 33 ui::kCursorZoomOut, | |
| 34 ui::kCursorGrab, | |
| 35 ui::kCursorGrabbing, | |
| 36 }; | |
| 37 | |
| 38 void LoadImageCursors(float device_scale_factor, ui::CursorLoader* loader) { | |
| 39 int resource_id; | |
| 40 gfx::Point point; | |
| 41 for (size_t i = 0; i < arraysize(kImageCursorIds); ++i) { | |
| 42 bool success = ui::GetCursorDataFor( | |
| 43 ui::CURSOR_SET_NORMAL, // Not support custom cursor set. | |
| 44 kImageCursorIds[i], | |
| 45 device_scale_factor, | |
| 46 &resource_id, | |
| 47 &point); | |
| 48 DCHECK(success); | |
| 49 loader->LoadImageCursor(kImageCursorIds[i], resource_id, point); | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 } // namespace | |
| 54 | |
| 55 DesktopCursorLoaderUpdaterAuraLinux::DesktopCursorLoaderUpdaterAuraLinux() {} | |
| 56 | |
| 57 DesktopCursorLoaderUpdaterAuraLinux::~DesktopCursorLoaderUpdaterAuraLinux() {} | |
| 58 | |
| 59 void DesktopCursorLoaderUpdaterAuraLinux::OnCreate( | |
| 60 float device_scale_factor, | |
| 61 ui::CursorLoader* loader) { | |
| 62 LoadImageCursors(device_scale_factor, loader); | |
| 63 } | |
| 64 | |
| 65 void DesktopCursorLoaderUpdaterAuraLinux::OnDisplayUpdated( | |
| 66 const display::Display& display, | |
| 67 ui::CursorLoader* loader) { | |
| 68 LoadImageCursors(display.device_scale_factor(), loader); | |
| 69 } | |
| 70 | |
| 71 // static | |
| 72 std::unique_ptr<DesktopCursorLoaderUpdater> | |
| 73 DesktopCursorLoaderUpdater::Create() { | |
| 74 return base::WrapUnique(new DesktopCursorLoaderUpdaterAuraLinux); | |
| 75 } | |
| 76 | |
| 77 } // namespace views | |
| OLD | NEW |