2 xkbd - xlib based onscreen keyboard.
4 Copyright (C) 2001 Matthew Allum
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
21 #include <X11/Xutil.h>
23 #include <X11/Xft/Xft.h>
25 #define BUTTON_PRESSED 0
26 #define BUTTON_RELEASED 1
27 #define BUTTON_LOCKED 2
29 #define KB_STATE_NORMAL 0
30 #define KB_STATE_SHIFT (1<<1)
31 #define KB_STATE_MOD (1<<2)
32 #define KB_STATE_CTRL (1<<3)
33 #define KB_STATE_CAPS (1<<4)
34 #define KB_STATE_META (1<<5)
35 #define KB_STATE_ALT (1<<6)
38 #define BUT_SHIFT (1<<1)
39 #define BUT_MOD (1<<2)
40 #define BUT_CTRL (1<<3)
41 #define BUT_CAPS (1<<4)
42 #define BUT_META (1<<5)
43 #define BUT_ALT (1<<6)
46 #define OPT_OBEYCAPS (1<<0)
58 #define KB_STATE_ALT_L (1<<1)
59 #define KB_STATE_ALT_R (1<<2)
60 #define KB_STATE_CTRL_L (1<<3)
61 #define KB_STATE_CTRL_R (1<<4)
62 #define KB_STATE_SHIFT_L (1<<5)
63 #define KB_STATE_SHIFT_R (1<<6)
76 enum { vbox, hbox } type;
79 int min_width; /* ( num_kids*(kid_c_width+(kid_border*2) ) */
81 int act_width; /* actual calculated width */
82 int act_height; /* ( num_kids*(kid_c_width+padding+(kid_border*2) ) */
83 int x; /* relative to parent ? */
86 struct _box *parent; /* pointer to parent keyboard */
90 typedef struct _keyboard
93 box *kbd_layouts[MAX_LAYOUTS];
95 box *vbox; /* container */
97 int x; /* but vbox contains this ? */
104 GC rev_gc; /* inverse gc of above */
105 GC txt_gc; /* gc's for button txt */
109 XFontStruct* font_info;
110 int state; /* shifted | caps | modded | normal */
111 int state_locked; /* shifted | modded | normal */
113 enum { oldskool, xft } render_type;
114 enum { rounded, square, plain } theme;
117 int key_delay_repeat; /* delay time before key repeat */
118 int key_repeat; /* delay time between key repeats */
121 XftDraw *xftdraw; /* xft aa bits */
131 typedef struct _button
133 int x; /* actual co-ords relative to window */
136 char *default_txt; /* default button txt */
137 KeySym default_ks; /* default button Xkeysym */
144 KeySym slide_down_ks;
145 KeySym slide_left_ks;
146 KeySym slide_right_ks;
148 enum { none, up, down, left, right } slide;
150 int modifier; /* set to BUT_ if key is shift,ctrl,caps etc */
152 int options; /* bit-field of OPT_* */
154 int c_width; /* width of contents ( min width ) */
155 int c_height; /* height of contents ( min height ) */
156 int x_pad; /* total padding horiz */
157 int y_pad; /* total padding vert */
158 int b_size; /* size of border in pixels */
159 /* eg. total width = c_width+pad_x+(2*b_size) */
161 Bool is_width_spec; /* width is specified in conf file */
162 int key_span_width; /* width in number of keys spanned */
167 keyboard *kb; /* pointer to parent keyboard */
168 box *parent; /* pointer to holding box */
170 GC fg_gc; /* gc's for 'general' button cols */
173 signed int layout_switch; /* Signals the button switches layout
174 set to -1 for no switch */
177 XftColor *xft_fg_col; /* xft */
178 XftColor *xft_bg_col;