aboutsummaryrefslogtreecommitdiff
path: root/src/ShortcutManager.cc
blob: 0809220b97d5e9ea4a24b34ca23f26cfa76596c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "ShortcutManager.hh"
#include "Debug.hh"

#include <iostream>

ShortcutManager::ShortcutManager() : m_last_placeholder_key(0) { }

void ShortcutManager::setLastPlaceHolderKey(unsigned int lastPlaceHolderKey_)
{
    m_last_placeholder_key = lastPlaceHolderKey_;
}

unsigned int ShortcutManager::getLastPlaceHolderKey()
{
    return m_last_placeholder_key;
}

void ShortcutManager::mapKeyToWindow(unsigned int key, FluxboxWindow* window)
{
    m_key_to_window_map[key] = window;
}

void ShortcutManager::removeWindow(FluxboxWindow* window)
{
    KeyToWindowMap::const_iterator it;
    for (it = m_key_to_window_map.begin(); it != m_key_to_window_map.end(); ++it) {
        if (it->second == window){
            fbdbg << "Remove mapping window[" << window
                  << "] key [" << it->first << "]" << std::endl;
            m_key_to_window_map.erase(it);
            return;
        }
    }
}

FluxboxWindow* ShortcutManager::getWindowForKey(unsigned int key)
{
    KeyToWindowMap::const_iterator it = m_key_to_window_map.find(key);
    if (it != m_key_to_window_map.end()) {
        return it->second;
    }
    else {
        return nullptr;
    }
}