Back to index

unity  6.0.0
KeyboardUtil.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2011 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Jason Smith <jason.smith@canonical.com>
00018  */
00019 
00020 #ifndef KEYBOARDUTIL_H
00021 #define KEYBOARDUTIL_H
00022 
00023 #include <glib.h>
00024 
00025 #include <X11/keysym.h>
00026 #include <X11/XKBlib.h>
00027 #include <X11/extensions/XKBgeom.h>
00028 
00029 namespace unity
00030 {
00031 namespace ui
00032 {
00033 
00034 class KeyboardUtil
00035 {
00036 public:
00037   KeyboardUtil(Display *display);
00038   ~KeyboardUtil();
00039 
00040   guint GetKeycodeAboveKeySymbol(KeySym key_symbol) const;
00041 
00042   static bool IsPrintableKeySymbol(KeySym key_symbol);
00043   static bool IsMoveKeySymbol(KeySym sym);
00044 
00045 private:
00046   bool CompareOffsets (int current_x, int current_y, int best_x, int best_y) const;
00047   guint ConvertKeyToKeycode (XkbKeyPtr key) const;
00048 
00049   bool FindKeyInGeometry(XkbGeometryPtr geo, char *key_name, int& res_section, XkbBoundsRec& res_bounds) const;
00050   bool FindKeyInSectionAboveBounds (XkbGeometryPtr geo, int section, XkbBoundsRec const& target_bounds, guint &keycode) const;
00051 
00052   XkbBoundsRec GetAbsoluteKeyBounds (XkbKeyPtr key, XkbRowPtr row, XkbSectionPtr section, XkbGeometryPtr geo) const;
00053 
00054   XkbDescPtr keyboard_;
00055   Display *display_;
00056 };
00057 
00058 }
00059 }
00060 
00061 #endif // KEYBOARDUTIL_H
00062