summaryrefslogtreecommitdiffstats
path: root/kxkb/layoutmap.h
blob: 3a71979659f3a9abcdb9682a3bab2f3865788e73 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// C++ Interface: tqlayoutmap
//
// Description: 
//
//
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef __LAYOUTMAP_H
#define __LAYOUTMAP_H

#include <assert.h>

#include <tqptrqueue.h>
#include <tqmap.h>

#include <kwinmodule.h>
#include <kdebug.h>

#include "kxkbconfig.h"


// LayoutInfo is used for sticky switching and per-window/application switching policy
struct LayoutState {
	const LayoutUnit& tqlayoutUnit;
	int group;
	
	LayoutState(const LayoutUnit& tqlayoutUnit_):
		tqlayoutUnit(tqlayoutUnit_),
		group(tqlayoutUnit_.defaultGroup)
	{
// 		kdDebug() << "new LayoutState " << tqlayoutUnit.toPair() << " group: " << group << endl;
	}
};


// LayoutMap is used for per-window or per-application switching policy
class LayoutMap {
	typedef TQPtrQueue<LayoutState> LayoutQueue;
	typedef TQMap<WId, LayoutQueue> WinLayoutMap;
	typedef TQMap<TQString, LayoutQueue> WinClassLayoutMap;

public:
	LayoutMap(const KxkbConfig& kxkbConfig);
//	void setConfig(const KxkbConfig& kxkbConfig);
	
	void setCurrentLayout(const LayoutUnit& tqlayoutUnit);
	void setCurrentGroup(int group);
	LayoutState& getNextLayout();
	LayoutState& getCurrentLayout();
	
	void setCurrentWindow(WId winId);
	void reset();
	
private:
    // pseudo-union
	LayoutQueue m_globalLayouts;
	WinLayoutMap m_winLayouts;
	WinClassLayoutMap m_appLayouts;
	
	const KxkbConfig& m_kxkbConfig;
	WId m_currentWinId;
	TQString m_currentWinClass; // only for SWITCH_POLICY_WIN_CLASS
	
	void initLayoutQueue(LayoutQueue& tqlayoutQueue);
	LayoutQueue& getCurrentLayoutQueue(WId winId);
	LayoutQueue& getCurrentLayoutQueueInternal(WId winId);
	void clearMaps();
};

#endif