summaryrefslogtreecommitdiffstats
path: root/kkbswitch/kbswitchapp.h
blob: bcd8a7b6c03ac19a3c58b2788d9a158576dd4eed (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/***************************************************************************
                          kbswitchapp.h  -  description
                             -------------------
    begin                : Sun Jul 1 2001
    copyright            : (C) 2001 by Leonid Zeitlin
    email                : lz@europe.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KBSWITCHAPP_H
#define KBSWITCHAPP_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tdeversion.h>
#include <kuniqueapplication.h>

//#include <tqmap.h>

#include "kbgroup.h"
#include "kbswitchtrayicon.h"
#include "kbconfig.h"
#include "xkeyboard.h"
#include "kbswitchintf.h"
#include "windowwatcher.h"

/*class KWinModule;

typedef struct _KBWinInfo {
  int groupno;
  int next_groupno;
} KBWinInfo;

typedef TQMap<WId, KBWinInfo> KBWindowMap;*/

/**
  *@author Leonid Zeitlin
  */

class KBSwitchApp : public KUniqueApplication {
  TQ_OBJECT
public: 
  KBSwitchApp();
  ~KBSwitchApp();
protected: // Protected methods
  /** No descriptions */
  bool x11EventFilter(XEvent *e);
private: // Private attributes
  /**  */
  bool m_force_group_setting;
  int m_cur_groupno;
  int m_next_groupno;
  XKeyboard m_xkb;
  /**  */
  KBSwitchTrayIcon * m_trayicon;
  /** No descriptions */
  KBConfig m_kbconf;
  KBSwitchIntf *m_intf;
#ifndef HAVE_LIBXKLAVIER  
  /** Window manager interface */
  //KWinModule *m_twin_module;
  /** Maps Window IDs to their keyboard groups */
  //KBWindowMap m_window_map;
  //KBWindowMap::iterator m_active_window;
  WindowWatcher *m_watcher;
  KBConfig::GroupScope m_watcher_type;
#endif  
private: // Private methods
  /** Update the tray icon to show the flag corresponding to the current keyboard group */
  void updateIcon(int groupno);
  /** No descriptions */
  void internalToggleGroups();
  /** No descriptions */
  void forceSetGroup(int groupno);
  /** No descriptions */
  /*int getNextGroup(int groupno) {
    return groupno >= m_kbconf.groupCount() - 1 ? 0 : groupno + 1;
  }*/
  /** No descriptions */
  void setStartGroup(int start_group);
  void adaptToGroup(int groupno);
#ifndef HAVE_LIBXKLAVIER  
  /** initialize Window groups map */
  //void resetWindowMap();
  /** Disable window manager notifications */
  //void disableKWinModule();
  /** Enable window manager notifications */
  //void enableKWinModule();
  /** adds a new window to the internal window map */
  //void addWindowToMap(WId window_id);
  void enableWatcher();
  void disableWatcher();
#endif  
  /** Set the current and next groups */
  void setGroups(int group, int next_group);
private slots: // Private slots
  /** No descriptions */
  void slotGroupSelected(int groupno);
  /** Select the next keyboard layout (wraps around) */
  void slotSelectNextGroup();
  /** Select the previous keyboard layout (wraps around) */
  void slotSelectPrevGroup();
  /** No descriptions */
  void slotPreferences();
  /** No descriptions */
  void reconfigure();
  /** Respond to XKB changing the current group */
  void slotXkbGroupChanged(int groupno);
  /** Respond to changing of active window - active it's kb group */
  //void slotWindowChanged(WId activeWindow);
  /** Respond to removal of a window - remote it from Window groups map */
  //void slotWindowRemoved(WId window);
  void slotWindowChanged(int groupno, int next_groupno);
  /** React to a change in KKBSwitch's user preferences,
    * made by user in Configure dialog */
  void slotPrefChanged();
};

#endif