KKBSwitch – keyboard layout indicator
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

singlewindowwatcher.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /***************************************************************************
  2. * Copyright (C) 2004 by Leonid Zeitlin *
  3. * lz@europe.com *
  4. * *
  5. * This program is free software; you can redistribute it and/or modify *
  6. * it under the terms of the GNU General Public License as published by *
  7. * the Free Software Foundation; either version 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #include "singlewindowwatcher.h"
  21. #include "kbconfig.h"
  22. #include <twinmodule.h>
  23. #include <kdebug.h>
  24. SingleWindowWatcher::SingleWindowWatcher(KBConfig *kbconf, TQObject *parent, const char *name)
  25. : WindowWatcher(kbconf, parent, name)
  26. {
  27. reset();
  28. }
  29. SingleWindowWatcher::~SingleWindowWatcher()
  30. {
  31. }
  32. void SingleWindowWatcher::windowRemoved(WId id)
  33. {
  34. m_window_map.remove(id);
  35. }
  36. void SingleWindowWatcher::activeWindowChanged(WId id)
  37. {
  38. if (id == 0) return; // no window is active
  39. m_active_window = m_window_map.find(id);
  40. if (m_active_window == m_window_map.end())
  41. addWindowToMap(id);
  42. emit windowChanged(m_active_window.data().groupno, m_active_window.data().next_groupno);
  43. }
  44. void SingleWindowWatcher::addWindowToMap(WId window_id)
  45. {
  46. KBWinInfo wininfo = { m_kbconf->default_groupno(),
  47. m_kbconf->getNextGroup(m_kbconf->default_groupno()) };
  48. m_active_window = m_window_map.insert(window_id, wininfo);
  49. }
  50. void SingleWindowWatcher::changeGroup(int groupno, int next_groupno)
  51. {
  52. if (m_active_window != m_window_map.end()) {
  53. m_active_window.data().groupno = groupno;
  54. m_active_window.data().next_groupno = next_groupno;
  55. }
  56. }
  57. void SingleWindowWatcher::reset()
  58. {
  59. m_window_map.clear();
  60. WId active_window = m_twin_module->activeWindow();
  61. if (active_window)
  62. addWindowToMap(active_window);
  63. else m_active_window = m_window_map.end();
  64. }
  65. #include "singlewindowwatcher.moc"