~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy

« back to all changes in this revision

Viewing changes to kcontrol/kxkb/layoutmap.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-11 14:04:48 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071011140448-v0eb7lxbb24zagca
Tags: 3.94.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// C++ Implementation: layoutmap
3
 
//
4
 
// Description: 
5
 
//
6
 
//
7
 
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006
8
 
//
9
 
// Copyright: See COPYING file that comes with this distribution
10
 
//
11
 
//
 
1
/*
 
2
 *  Copyright (C) 2006 Andriy Rysin (rysin@kde.org)
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 */
 
18
 
12
19
 
13
20
#include <QX11Info>
 
21
#include <kwindowsystem.h>
14
22
 
15
23
#include "layoutmap.h"
16
24
 
45
53
        m_currentWinId = winId;
46
54
        if( m_kxkbConfig.m_switchingPolicy == SWITCH_POLICY_WIN_CLASS )
47
55
                m_currentWinClass = X11Helper::getWindowClass(winId, QX11Info::display());
 
56
        else
 
57
        if( m_kxkbConfig.m_switchingPolicy == SWITCH_POLICY_DESKTOP )
 
58
                m_currentDesktop = KWindowSystem::currentDesktop();
48
59
}
49
60
 
50
61
// private
51
62
//LayoutQueue& 
52
 
QQueue<int>& LayoutMap::getCurrentLayoutQueueInternal(WId winId)
 
63
QQueue<int>& LayoutMap::getCurrentLayoutQueueInternal()
53
64
{
54
 
        if( winId == X11Helper::UNKNOWN_WINDOW_ID )
 
65
        if( m_currentWinId == X11Helper::UNKNOWN_WINDOW_ID )
55
66
                return m_globalLayouts;
56
67
        
57
68
        switch( m_kxkbConfig.m_switchingPolicy ) {
60
71
                        return m_appLayouts[ m_currentWinClass ];
61
72
                }
62
73
                case SWITCH_POLICY_WINDOW:
63
 
                        return m_winLayouts[ winId ];
64
 
 
 
74
                        return m_winLayouts[ m_currentWinId ];
 
75
                case SWITCH_POLICY_DESKTOP:
 
76
                        return m_winLayouts[ m_currentDesktop ];
65
77
                default:
66
78
                        return m_globalLayouts;
67
79
        }
68
80
}
69
81
 
 
82
//private
 
83
QString LayoutMap::getOwner()
 
84
{
 
85
        switch( m_kxkbConfig.m_switchingPolicy ) {
 
86
                case SWITCH_POLICY_WIN_CLASS:
 
87
                        return QString("winclass: %1").arg(m_currentWinClass);
 
88
                case SWITCH_POLICY_WINDOW:
 
89
                        return QString("window: %1").arg(m_currentWinId);
 
90
                case SWITCH_POLICY_DESKTOP:
 
91
                        return QString("desktop: %1").arg(m_currentDesktop);
 
92
                default:
 
93
                        return "global";
 
94
        }
 
95
}
 
96
 
70
97
// private
71
98
//LayoutQueue& 
72
 
QQueue<int>& LayoutMap::getCurrentLayoutQueue(WId winId)
 
99
QQueue<int>& LayoutMap::getCurrentLayoutQueue()
73
100
{
74
 
        QQueue<int>& layoutQueue = getCurrentLayoutQueueInternal(winId);
 
101
        QQueue<int>& layoutQueue = getCurrentLayoutQueueInternal();
75
102
        if( layoutQueue.count() == 0 ) {
76
103
                initLayoutQueue(layoutQueue);
77
 
                kDebug() << "map: Created queue for " << winId << " size: " << layoutQueue.count();
 
104
                kDebug() << "Created queue for " << getOwner() << " size: " << layoutQueue.count();
78
105
        }
79
106
        
80
107
        return layoutQueue;
81
108
}
82
109
 
83
110
int LayoutMap::getCurrentLayout() {
84
 
        return getCurrentLayoutQueue(m_currentWinId).head();
 
111
        return getCurrentLayoutQueue().head();
85
112
}
86
113
 
87
114
int LayoutMap::getNextLayout() {
88
 
        LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId);
 
115
        LayoutQueue& layoutQueue = getCurrentLayoutQueue(/*m_currentWinId*/);
89
116
        int layoutState = layoutQueue.dequeue();
90
117
        layoutQueue.enqueue(layoutState);
91
118
        
92
119
        kDebug() << "map: Next layout: " << layoutQueue.head() 
93
120
//                      << " group: " << layoutQueue.head()->layoutUnit.defaultGroup 
94
 
                        << " for " << m_currentWinId << endl;
 
121
                        << " for " << getOwner();
95
122
        
96
123
        return layoutQueue.head();
97
124
}
98
125
 
99
126
void LayoutMap::setCurrentLayout(int layoutUnit) {
100
 
        LayoutQueue& layoutQueue = getCurrentLayoutQueue(m_currentWinId);
 
127
        LayoutQueue& layoutQueue = getCurrentLayoutQueue(/*m_currentWinId*/);
101
128
        kDebug() << "map: Storing layout: " << layoutUnit 
102
129
//                      << " group: " << layoutUnit.defaultGroup 
103
 
                        << " for " << m_currentWinId << endl;
 
130
                        << " for " << getOwner();
104
131
        
105
132
        int queueSize = (int)layoutQueue.count();
106
133
        for(int ii=0; ii<queueSize; ii++) {