| 1 |
/* |
| 2 |
* Copyright (C) 2017-2024 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 |
#pragma once |
| 10 |
|
| 11 |
#include <set> |
| 12 |
#include <string> |
| 13 |
#include <vector> |
| 14 |
|
| 15 |
class CWindowTranslator |
| 16 |
{ |
| 17 |
public: |
| 18 |
/*! |
| 19 |
* \brief Get a list of all known window names |
| 20 |
*/ |
| 21 |
static void GetWindows(std::vector<std::string>& windowList); |
| 22 |
|
| 23 |
/*! |
| 24 |
* \brief Translate between a window name and its ID |
| 25 |
* \param window The name of the window |
| 26 |
* \return ID of the window, or WINDOW_INVALID if not found |
| 27 |
*/ |
| 28 |
static int TranslateWindow(const std::string& window); |
| 29 |
|
| 30 |
/*! |
| 31 |
* \brief Translate between a window id and it's name |
| 32 |
* \param window id of the window |
| 33 |
* \return name of the window, or an empty string if not found |
| 34 |
*/ |
| 35 |
static std::string TranslateWindow(int windowId); |
| 36 |
|
| 37 |
/*! |
| 38 |
* \brief Get the window ID that should be used as fallback for keymap input |
| 39 |
* \return The fallback window, or -1 for no fallback window |
| 40 |
*/ |
| 41 |
static int GetFallbackWindow(int windowId); |
| 42 |
|
| 43 |
/*! |
| 44 |
* \brief Get the special window ID if conditions met |
| 45 |
* \return The special window ID or the given window ID |
| 46 |
*/ |
| 47 |
static int GetVirtualWindow(int windowId); |
| 48 |
|
| 49 |
private: |
| 50 |
struct WindowMapItem |
| 51 |
{ |
| 52 |
const char* windowName; |
| 53 |
int windowId; |
| 54 |
}; |
| 55 |
|
| 56 |
struct WindowNameCompare |
| 57 |
{ |
| 58 |
bool operator()(const WindowMapItem& lhs, const WindowMapItem& rhs) const; |
| 59 |
}; |
| 60 |
|
| 61 |
struct WindowIDCompare |
| 62 |
{ |
| 63 |
bool operator()(const WindowMapItem& lhs, const WindowMapItem& rhs) const; |
| 64 |
}; |
| 65 |
|
| 66 |
using WindowMapByName = std::set<WindowMapItem, WindowNameCompare>; |
| 67 |
using WindowMapByID = std::set<WindowMapItem, WindowIDCompare>; |
| 68 |
|
| 69 |
static WindowMapByID CreateWindowMappingByID(); |
| 70 |
|
| 71 |
static const WindowMapByName WindowMappingByName; |
| 72 |
}; |