1 // Copyright (c) 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_aurax11.h" 6 7 #include "ui/aura/root_window.h" 8 #include "ui/base/cursor/cursor_loader.h" 9 #include "ui/base/cursor/cursors_aura.h" 10 #include "ui/gfx/display.h" 11 12 namespace views { 13 namespace { 14 15 // Cursors that we need to supply our own image resources for. This was 16 // generated from webcursor_gtk.cc; any cursor that either was NOTIMPLEMENTED() 17 // or already was implemented with a pixmap is on this list. 18 const int kImageCursorIds[] = { 19 ui::kCursorNorthEastSouthWestResize, 20 ui::kCursorNorthWestSouthEastResize, 21 ui::kCursorVerticalText, 22 ui::kCursorCell, 23 ui::kCursorContextMenu, 24 ui::kCursorAlias, 25 ui::kCursorNoDrop, 26 ui::kCursorCopy, 27 ui::kCursorNotAllowed, 28 ui::kCursorZoomIn, 29 ui::kCursorZoomOut, 30 ui::kCursorGrab, 31 ui::kCursorGrabbing, 32 }; 33 34 void LoadImageCursors(float device_scale_factor, ui::CursorLoader* loader) { 35 int resource_id; 36 gfx::Point point; 37 for (size_t i = 0; i < arraysize(kImageCursorIds); ++i) { 38 bool success = ui::GetCursorDataFor(kImageCursorIds[i], device_scale_factor, 39 &resource_id, &point); 40 DCHECK(success); 41 loader->LoadImageCursor(kImageCursorIds[i], resource_id, point); 42 } 43 } 44 45 } // namespace 46 47 DesktopCursorLoaderUpdaterAuraX11::DesktopCursorLoaderUpdaterAuraX11() {} 48 49 DesktopCursorLoaderUpdaterAuraX11::~DesktopCursorLoaderUpdaterAuraX11() {} 50 51 void DesktopCursorLoaderUpdaterAuraX11::OnCreate( 52 aura::RootWindow* window, 53 ui::CursorLoader* loader) { 54 LoadImageCursors(window->compositor()->device_scale_factor(), loader); 55 } 56 57 void DesktopCursorLoaderUpdaterAuraX11::OnDisplayUpdated( 58 const gfx::Display& display, 59 ui::CursorLoader* loader) { 60 LoadImageCursors(display.device_scale_factor(), loader); 61 } 62 63 } // namespace views 64