KKBSwitch – keyboard layout indicator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xkeyboard.h 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /***************************************************************************
  2. xkeyboard.h - description
  3. -------------------
  4. begin : Sun Jul 8 2001
  5. copyright : (C) 2001 by Leonid Zeitlin
  6. email : lz@europe.com
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #ifndef XKEYBOARD_H
  17. #define XKEYBOARD_H
  18. #include "config.h"
  19. #include <ntqobject.h>
  20. #include <X11/Xlib.h>
  21. #include <X11/XKBlib.h>
  22. #ifdef HAVE_LIBXKLAVIER
  23. #include <libxklavier/xklavier.h>
  24. #endif
  25. class TQStringList;
  26. /**This class incapsulates XKeyboard Extension interface
  27. *@author Leonid Zeitlin
  28. */
  29. class XKeyboard : public TQObject {
  30. Q_OBJECT
  31. private:
  32. #ifndef HAVE_LIBXKLAVIER
  33. int m_event_code;
  34. int m_numgroups;
  35. #endif
  36. static XKeyboard *m_self;
  37. bool m_xkb_available;
  38. public:
  39. static const int MaxNumKbdGroups = XkbNumKbdGroups;
  40. XKeyboard();
  41. ~XKeyboard();
  42. /** Set the current keyboard group to the given groupno */
  43. void setGroupNo(int groupno);
  44. /** Get the names of the currently configured keyboard groups */
  45. void getGroupNames(TQStringList &list);
  46. static XKeyboard* self();
  47. /** return the current keyboard group index */
  48. int getGroupNo();
  49. /** return if XKEYBOARD extension is available in the X server */
  50. bool xkbAvailable() { return m_xkb_available; }
  51. #ifdef HAVE_LIBXKLAVIER
  52. int getNumKbdGroups() { return XklGetNumGroups(); };
  53. #else
  54. int getNumKbdGroups() { return m_numgroups; };
  55. #endif
  56. /** Examines an X Event passed to it and takes actions if the event is of
  57. * interest to XKeyboard */
  58. void processEvent(XEvent *ev);
  59. private: // Private methods
  60. #ifdef HAVE_LIBXKLAVIER
  61. static void XklStateCallback(XklStateChange changeType, int group,
  62. Bool /*restore*/, void* /*userData*/);
  63. static void XklConfigCallback(void */*userData*/);
  64. static void XklLogAppender(const char file[], const char function[],
  65. int level, const char format[], va_list args);
  66. #else
  67. /** No descriptions */
  68. void retrieveNumKbdGroups();
  69. #endif
  70. signals: // Signals
  71. /** Signals that new keyboard group is selected */
  72. void groupChanged(int groupno);
  73. /** Signals that keyboard layout has changed and thus we need to reconfigure */
  74. void layoutChanged();
  75. };
  76. #endif