OpenTracker

An Open Architecture for Reconfigurable Tracking based on XML | Contact

XKeys.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------
00002 //                Institute for Computer Graphics and Vision
00003 //                  (c) 2002,2003,2004 All Rights Reserved
00004 //----------------------------------------------------------------------
00005 // @author  Bernhard Reitinger
00006 // created  Thu Jul 14 09:29:17 2005
00007 //----------------------------------------------------------------------
00008 // $Id$
00009 //----------------------------------------------------------------------
00010 
00017 #ifndef _OT_XKEYS_H
00018 #define _OT_XKEYS_H
00019 
00020 // this is a linux implementation !!!
00021 #ifndef WIN32
00022 
00023 #include <X11/Xlib.h>
00024 #include <iostream>
00025 #include <string>
00026 
00033 namespace ot {
00034 
00035    class XKeys {
00036 
00037    public:
00038       typedef enum {
00039      SYM, 
00040      CODE, 
00041      BUTTON 
00042       } KeyType_t;
00043       
00044       typedef enum { 
00045      PRESS, 
00046      RELEASE
00047       } EventType_t;
00048       
00049       typedef struct {
00050      KeyType_t type;
00051      EventType_t event_type;
00052      
00053      union {
00054         KeySym sym;
00055         KeyCode code;
00056         unsigned int button;
00057      } key;
00058      
00059      unsigned int modifier;
00060      char *command;
00061       } Keys_t;
00062 
00063 
00064    public:
00065 
00066       // ctor
00067       XKeys()
00068       { init(); }
00069 
00070       // ctor
00071       XKeys(const char* rcfile);
00072 
00073       // dtor
00074       ~XKeys()
00075       { freeKeys(); }
00076 
00077       // this method loads the RC file by xbindkeys
00078       bool loadRC(const char* rcfile);
00079 
00080       void showKeys(Display * d);
00081       void print_key(Display * d, Keys_t * key);
00082       void grab_keys (Display * dpy);
00083 
00084    protected:
00085       
00086       void init();
00087       void initKeys();
00088       void freeKeys();
00089 
00090       bool add_key(KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keycode,
00091            unsigned int button, unsigned int modifier, char *command, const char* rc_file);
00092 
00093       
00094       void set_keysym (Keys_t * key, EventType_t event_type, KeySym keysym,
00095                unsigned int modifier, char *command);
00096       void set_keycode (Keys_t * key, EventType_t event_type, KeySym keycode, 
00097             unsigned int modifier, char *command);
00098       void set_button (Keys_t * key, EventType_t event_type, unsigned int button, 
00099                unsigned int modifier, char *command);
00100       void free_key (Keys_t * key);
00101 
00102       void modifier_to_string (unsigned int modifier, char *str);
00103 
00104       void my_grab_button (Display * dpy, unsigned int button, unsigned int modifier,
00105                Window win);
00106       void my_grab_key (Display * dpy, KeyCode keycode, unsigned int modifier,
00107             Window win);
00108 
00109    public:
00110 
00111       int nb_keys;
00112       Keys_t *keys;
00113 
00114       unsigned int numlock_mask;
00115       unsigned int scrolllock_mask;
00116       unsigned int capslock_mask;
00117 
00118       
00119    protected:
00120      
00121       bool verbose;
00122       
00123    };
00124 }
00125 
00126 // win32
00127 #endif
00128 
00129 #endif
00130 
00131 /* 
00132  * ------------------------------------------------------------
00133  *   End of XKeys.h
00134  * ------------------------------------------------------------
00135  *   Automatic Emacs configuration follows.
00136  *   Local Variables:
00137  *   mode:c++
00138  *   c-basic-offset: 4
00139  *   eval: (c-set-offset 'substatement-open 0)
00140  *   eval: (c-set-offset 'case-label '+)
00141  *   eval: (c-set-offset 'statement 'c-lineup-runin-statements)
00142  *   eval: (setq indent-tabs-mode nil)
00143  *   End:
00144  * ------------------------------------------------------------ 
00145  */

copyright (c) 2006 Graz University of Technology