Debian Codegraph @

xbmc/windowing/wayland/Util.cpp

raw
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "Util.h"
10
11 #include <map>
12 #include <string>
13
14 #include <wayland-cursor.hpp>
15
16 namespace
17 {
18 /*
19 * List from gdkcursor-wayland.c
20 *
21 * GDK - The GIMP Drawing Kit
22 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
23 *
24 * SPDX-License-Identifier: LGPL-2.1-or-later
25 * See LICENSES/README.md for more information.
26 */
27 static std::map<std::string, std::string> CursorFallbackNameMap =
28 {
29 { "default", "left_ptr" },
30 { "help", "question_arrow" },
31 { "context-menu", "left_ptr" },
32 { "pointer", "hand" },
33 { "progress", "left_ptr_watch" },
34 { "wait", "watch" },
35 { "cell", "crosshair" },
36 { "crosshair", "cross" },
37 { "text", "xterm" },
38 { "vertical-text","xterm" },
39 { "alias", "dnd-link" },
40 { "copy", "dnd-copy" },
41 { "move", "dnd-move" },
42 { "no-drop", "dnd-none" },
43 { "dnd-ask", "dnd-copy" }, // not CSS, but we want to guarantee it anyway
44 { "not-allowed", "crossed_circle" },
45 { "grab", "hand2" },
46 { "grabbing", "hand2" },
47 { "all-scroll", "left_ptr" },
48 { "col-resize", "h_double_arrow" },
49 { "row-resize", "v_double_arrow" },
50 { "n-resize", "top_side" },
51 { "e-resize", "right_side" },
52 { "s-resize", "bottom_side" },
53 { "w-resize", "left_side" },
54 { "ne-resize", "top_right_corner" },
55 { "nw-resize", "top_left_corner" },
56 { "se-resize", "bottom_right_corner" },
57 { "sw-resize", "bottom_left_corner" },
58 { "ew-resize", "h_double_arrow" },
59 { "ns-resize", "v_double_arrow" },
60 { "nesw-resize", "fd_double_arrow" },
61 { "nwse-resize", "bd_double_arrow" },
62 { "zoom-in", "left_ptr" },
63 { "zoom-out", "left_ptr" }
64 };
65
66 }
67
68 using namespace KODI::WINDOWING::WAYLAND;
69
70 wayland::cursor_t CCursorUtil::LoadFromTheme(wayland::cursor_theme_t const& theme, std::string const& name)
71 {
72 try
73 {
74 return theme.get_cursor(name);
75 }
76 catch (std::exception const&)
77 {
78 auto i = CursorFallbackNameMap.find(name);
79 if (i == CursorFallbackNameMap.end())
80 {
81 throw;
82 }
83 else
84 {
85 return theme.get_cursor(i->second);
86 }
87 }
88 }