Browse Source

Initial commit with version 0.21.

master
Olaf Schulz 10 years ago
parent
commit
6d64acdb17
  1. 49
      Makefile
  2. 9
      README
  3. BIN
      assets/icons/Neo-Icon.png
  4. BIN
      assets/neo2.1/tastatur_neo_Ebene1.png
  5. BIN
      assets/neo2.1/tastatur_neo_Ebene2.png
  6. BIN
      assets/neo2.1/tastatur_neo_Ebene3.png
  7. BIN
      assets/neo2.1/tastatur_neo_Ebene4.png
  8. BIN
      assets/neo2.1/tastatur_neo_Ebene5.png
  9. BIN
      assets/neo2.1/tastatur_neo_Ebene6.png
  10. 129
      config-manager.vala
  11. 609
      key-overlay.vala
  12. 310
      keybinding-manager.vala
  13. 435
      neo2.vala
  14. 60
      tray.vala
  15. 8289
      vapi/gtk+-2.0.vapi
  16. 4
      vapi/gtk+-2.0.vapi.diff
  17. 56
      vapi/keysym.vapi

49
Makefile

@ -0,0 +1,49 @@
# Makefile
# vala project
#
# name of your project/program
PROGRAM = neo_layout_viewer
BINDIR = bin
# for most cases the following two are the only you'll need to change
# add your source files here
SRC = neo2.vala key-overlay.vala tray.vala config-manager.vala keybinding-manager.vala
# add your used packges here
PKGS = --pkg x11 --pkg keysym --pkg gtk+-2.0 --pkg gee-1.0 --pkg gdk-x11-2.0 --pkg posix
#PKGS = --pkg keysym --pkg x11 --pkg gtk+-2.0 --pkg gee-1.0 --pkg gdk-x11-2.0 --pkg posix
CC_INCLUDES =
# vala compiler
VALAC = valac
#VAPIDIR = --vapidir=vapi/
VAPIDIR = --vapi=vapi/keysym.vapi
# compiler options for a debug build
VALACOPTS = -g --save-temps
# set this as root makefile for Valencia
BUILD_ROOT = 1
# the 'all' target build a debug build
all: $(BINDIR) bulid_debug
# the 'release' target builds a release build
# you might want to disabled asserts also
release: $(BINDIR) clean bulid_release
$(BINDIR):
mkdir -p $(BINDIR)
ln -s ../assets bin/assets
bulid_debug:
@$(VALAC) $(VAPIDIR) $(VALACOPTS) $(SRC) -o $(BINDIR)/$(PROGRAM) $(PKGS) $(CC_INCLUDES)
bulid_release:
@$(VALAC) -X -O2 $(VAPIDIR) $(SRC) -o $(BINDIR)/$(PROGRAM)_release $(PKGS) $(CC_INCLUDES)
# clean all built files
clean:
@rm -v -fr *~ *.c $(PROGRAM)

9
README

@ -0,0 +1,9 @@
Errors:
Not all keysyms found. make returns i.e.
[..]/key-overlay.c:1744: error: ‘XK_logicalor’ undeclared (first use in this function)
Solution: define all groups in /etc/include/X11/keysym.def. I.e. add “#define XK_TECHNICAL“.

BIN
assets/icons/Neo-Icon.png

After

Width: 100  |  Height: 100  |  Size: 6.7 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene1.png

After

Width: 1000  |  Height: 220  |  Size: 135 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene2.png

After

Width: 1000  |  Height: 220  |  Size: 137 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene3.png

After

Width: 1000  |  Height: 220  |  Size: 130 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene4.png

After

Width: 1000  |  Height: 220  |  Size: 133 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene5.png

After

Width: 1000  |  Height: 220  |  Size: 137 KiB

BIN
assets/neo2.1/tastatur_neo_Ebene6.png

After

Width: 1000  |  Height: 220  |  Size: 136 KiB

129
config-manager.vala

@ -0,0 +1,129 @@
namespace NeoLayoutViewer{
class ConfigManager {
//public Gee.HashMap<string,string> config = new Gee.HashMax<string,string>();
//public Gee.HashMap<string,string> config { get; set; default = new Gee.HashMap<string, string>();};
public Gee.HashMap<string,string> config;// { get; set; };
public ConfigManager(string conffile) {
this.config = new Gee.HashMap<string, string>();
//add defaults values, if key not set in the config file
add_defaults();
if(!search_config_file(conffile))
create_conf_file(conffile);
if(search_config_file(conffile))
load_config_file(conffile);
add_intern_values();
}
public Gee.HashMap<string, string> getConfig(){
return config;
}
/*
Standardwerte der Einstellungen. Sie werden in eine Konfigurationsdatei geschrieben, falls
diese Datei nicht vorhanden ist.
*/
public void add_defaults(){
config.set("show_shortcut","<Mod4><Super_L>N");
config.set("on_top","1");
config.set("position","5");
config.set("width","1000");//Skalierung, sofern wert zwischen width(resolution)*max_width und width(resolution)*min_width
config.set("min_width","0.25");//Relativ zur Auflösung
config.set("max_width","0.5");//Relativ zur Auflösung
config.set("move_shortcut","<Mod4><Super_L>R");
//config.set("position_cycle","3 3 9 1 3 9 1 7 7");
config.set("position_cycle","2 3 6 1 3 9 4 7 8");
config.set("display_numblock","1");
}
/*
Einstellungen, die der Übersicht halber nicht in der Konfigurationsdatei stehen.
*/
private void add_intern_values(){
config.set("numblock_width","350");
}
private bool search_config_file(string conffile){
var file = File.new_for_path (conffile);
return file.query_exists(null);
}
private int create_conf_file(string conffile){
var file = File.new_for_path (conffile);
try{
//Create a new file with this name
var file_stream = file.create (FileCreateFlags.NONE);
// Test for the existence of file
if (! file.query_exists ()) {
stdout.printf ("Can't create config file.\n");
return -1;
}
// Write text data to file
var data_stream = new DataOutputStream (file_stream);
/*
data_stream.put_string ("#Show/Hide the window\n");
data_stream.put_string ("show_shortcut=<Ctrl><Alt>R\n");
data_stream.put_string ("#Show window on top\n");
data_stream.put_string ("on_top=1\n");
*/
foreach( Gee.Map.Entry<string, string> e in this.config.entries){
data_stream.put_string ( e.key+" = "+e.value+"\n" );
}
} // Streams
catch ( GLib.IOError e){ return -1; }
catch ( GLib.Error e){ return -1; }
return 0;
}
private int load_config_file(string conffile){
// A reference to our file
var file = File.new_for_path (conffile);
try {
// Open file for reading and wrap returned FileInputStream into a
// DataInputStream, so we can read line by line
var in_stream = new DataInputStream (file.read (null));
string line;
string[] split;
var comment = new Regex("^#.*$");
var regex = new Regex("(#[^=]*)*[ ]*=[ ]*");
// Read lines until end of file (null) is reached
while ((line = in_stream.read_line (null, null)) != null) {
//stdout.printf ("%s\n", line);
if( comment.match(line)) continue;
split = regex.split(line);
if(split.length>1){
//debug(split[0]+" "+split[1]+"\n");
this.config.set(split[0],split[1]);
}
}
} catch (GLib.IOError e) {
error ("%s", e.message);
//return -1;
} catch (RegexError e) {
error ("%s", e.message);
//return -1;
}catch (GLib.Error e) {
error ("%s", e.message);
//return -1;
}
return 0;
}
}
}

609
key-overlay.vala

@ -0,0 +1,609 @@
/*
Known Problems:
- Tab, Shift+Tab, Shift+Space, Numblock not implemented
- Some special characters, i.e ℂ, not implemented, because the unicode numbers
not defined in keysymdef.h (and left in the vapi file, too).
*/
using Gtk;
using Gdk;
using X;
//using Keysym;//keysymdef.h
using Posix;//system-call
namespace NeoLayoutViewer{
private class ArrayBox {
public uint[] val;
public ArrayBox(uint[] val){
this.val = val;
}
}
public class KeyOverlay : VBox {
public Gee.HashMap<int,KeyEventBox> keyBoxes;
public Gee.HashMap<int,ArrayBox> keysyms;
private NeoWindow winMain;
public KeyOverlay(NeoWindow winMain) {
//base(true,0);
this.set_homogeneous(false);
this.set_spacing(0);
this.winMain = winMain;
this.keysyms = generateKeysyms();
this.keyBoxes = new Gee.HashMap<int, KeyEventBox>();
generateKeyevents();
}
public Gee.HashMap<int, ArrayBox> generateKeysyms(){
keysyms = new Gee.HashMap<int, ArrayBox>();
keysyms.set(8, new ArrayBox({}));
keysyms.set(9, new ArrayBox({XK_Escape, 0, XK_Escape}));
keysyms.set(10, new ArrayBox({XK_1, XK_degree, XK_onesuperior, XK_onesubscript, XK_ordfeminine, 0, XK_notsign}));
keysyms.set(11, new ArrayBox({XK_2, XK_section, XK_twosuperior, XK_twosubscript, XK_masculine, 0, XK_logicalor}));
keysyms.set(12, new ArrayBox({XK_3, 0, XK_threesuperior, XK_threesubscript, XK_numerosign, 0, XK_logicaland}));
keysyms.set(13, new ArrayBox({XK_4, XK_guillemotright, 0, 0, XK_Prior, XK_Prior, 0}));
keysyms.set(14, new ArrayBox({XK_5, XK_guillemotleft, 0, 0, XK_periodcentered, 0, 0}));
keysyms.set(15, new ArrayBox({XK_6, XK_EuroSign, XK_cent, 0, XK_sterling, 0, 0}));
keysyms.set(16, new ArrayBox({XK_7, XK_dollar, XK_yen, XK_Greek_kappa, XK_currency, 0, XK_rightarrow}));
keysyms.set(17, new ArrayBox({XK_8, 0, 0, 0, 0, 0, 0}));
keysyms.set(18, new ArrayBox({XK_9, 0, 0, 0, XK_slash, 0, XK_containsas}));
keysyms.set(19, new ArrayBox({XK_0, 0, XK_zerosubscript, XK_asterisk, 0, XK_emptyset}));
keysyms.set(20, new ArrayBox({XK_minus, 0, 0, 0, XK_minus, 0, XK_hyphen}));
keysyms.set(21, new ArrayBox({XK_dead_grave, 0, XK_dead_diaeresis, XK_dead_abovereversedcomma}));
keysyms.set(22, new ArrayBox({XK_BackSpace, XK_BackSpace, XK_BackSpace, XK_BackSpace, XK_BackSpace, XK_BackSpace, XK_BackSpace}));
keysyms.set(23, new ArrayBox({XK_Tab, XK_ISO_Left_Tab, XK_Multi_key}));
keysyms.set(24, new ArrayBox({XK_x, XK_X, 0, XK_Greek_xi, 0, 0, XK_Greek_XI}));
keysyms.set(25, new ArrayBox({XK_v, XK_V, XK_underscore, 0, XK_BackSpace, XK_BackSpace, 0}));
keysyms.set(26, new ArrayBox({XK_l, XK_L, XK_bracketleft, XK_Greek_lamda, XK_Up, XK_Up, XK_Greek_LAMDA}));
keysyms.set(27, new ArrayBox({XK_c, XK_C, XK_bracketright, XK_Greek_chi, XK_Delete, XK_Delete, 0}));
keysyms.set(28, new ArrayBox({XK_w, XK_W, XK_asciicircum, XK_Greek_omega, XK_Insert, XK_Insert, XK_Greek_OMEGA}));
keysyms.set(29, new ArrayBox({XK_k, XK_K, XK_exclam, 0, XK_exclamdown, 0, XK_radical}));
keysyms.set(30, new ArrayBox({XK_h, XK_H, XK_less, XK_Greek_psi, XK_7, 0, XK_Greek_PSI}));
keysyms.set(31, new ArrayBox({XK_g, XK_G, XK_greater, XK_Greek_gamma, XK_8, 0, XK_Greek_GAMMA}));
keysyms.set(32, new ArrayBox({XK_f, XK_F, XK_equal, XK_Greek_phi, XK_9, 0, XK_Greek_PHI}));
keysyms.set(33, new ArrayBox({XK_q, XK_Q, XK_ampersand, 0, XK_plus, 0, 0}));
keysyms.set(34, new ArrayBox({XK_ssharp, 0, 0, XK_Greek_finalsmallsigma, 0, 0, 0}));
keysyms.set(35, new ArrayBox({XK_dead_acute, XK_dead_cedilla, XK_dead_stroke, XK_dead_abovecomma, XK_dead_doubleacute, 0, XK_dead_abovedot}));
keysyms.set(36, new ArrayBox({XK_Return, 0, XK_Return}));
keysyms.set(37, new ArrayBox({XK_Control_L, 0, XK_Control_L}));
keysyms.set(38, new ArrayBox({XK_u, XK_U, XK_backslash, 0, XK_Home, XK_Home, 0}));
keysyms.set(39, new ArrayBox({XK_i, XK_I, XK_slash, XK_Greek_iota, XK_Left, XK_Left, XK_integral}));
keysyms.set(40, new ArrayBox({XK_a, XK_A, XK_braceleft, XK_Greek_alpha, XK_Down, XK_Down, 0}));
keysyms.set(41, new ArrayBox({XK_e, XK_E, XK_braceright, XK_Greek_epsilon, XK_Right, XK_Right, 0}));
keysyms.set(42, new ArrayBox({XK_o, XK_O, XK_asterisk, XK_Greek_omicron, XK_End, XK_End, XK_elementof}));
keysyms.set(43, new ArrayBox({XK_s, XK_S, XK_question, XK_Greek_sigma, XK_questiondown, 0, XK_Greek_SIGMA}));
keysyms.set(44, new ArrayBox({XK_n, XK_N, XK_parenleft, XK_Greek_nu, XK_4, 0, 0}));
keysyms.set(45, new ArrayBox({XK_r, XK_R, XK_parenright, 0, XK_5, 0, 0}));
keysyms.set(46, new ArrayBox({XK_t, XK_T, XK_minus, XK_Greek_tau, XK_6, 0, XK_partialderivative}));
keysyms.set(47, new ArrayBox({XK_d, XK_D, XK_colon, XK_Greek_delta, XK_comma, 0, XK_Greek_DELTA}));
keysyms.set(48, new ArrayBox({XK_y, XK_Y, XK_at, XK_Greek_upsilon, XK_period, 0, XK_nabla}));
keysyms.set(49, new ArrayBox({XK_dead_circumflex, XK_dead_tilde, XK_dead_abovering, XK_dead_breve, XK_dead_caron, 0, XK_dead_macron}));
keysyms.set(50, new ArrayBox({XK_Shift_L, 0, XK_Shift_L}));
keysyms.set(51, new ArrayBox({XK_ISO_Level3_Shift, XK_ISO_Level3_Shift, XK_Caps_Lock, XK_Caps_Lock}));
keysyms.set(52, new ArrayBox({XK_udiaeresis, XK_Udiaeresis, XK_numbersign, 0, XK_Escape, XK_Escape, 0}));
keysyms.set(53, new ArrayBox({XK_odiaeresis, XK_Odiaeresis, XK_dollar, 0, XK_Tab, XK_Tab, 0}));
keysyms.set(54, new ArrayBox({XK_adiaeresis, XK_Adiaeresis, XK_bar, XK_Greek_eta, XK_Next, XK_Next, 0}));
keysyms.set(55, new ArrayBox({XK_p, XK_P, XK_asciitilde, XK_Greek_pi, XK_Return, XK_Return, XK_Greek_PI}));
keysyms.set(56, new ArrayBox({XK_z, XK_Z, XK_grave, XK_Greek_zeta, 0, 0, 0}));
keysyms.set(57, new ArrayBox({XK_b, XK_B, XK_plus, XK_Greek_beta, XK_colon, 0, 0}));
keysyms.set(58, new ArrayBox({XK_m, XK_M, XK_percent, XK_Greek_mu, XK_1, 0, XK_ifonlyif}));
keysyms.set(59, new ArrayBox({XK_comma, 0, XK_quotedbl, XK_Greek_rho, XK_2, 0, 0}));
keysyms.set(60, new ArrayBox({XK_period, 0, XK_apostrophe, 0, XK_3, 0, XK_Greek_THETA}));
keysyms.set(61, new ArrayBox({XK_j, XK_J, XK_semicolon, XK_Greek_theta, XK_semicolon, 0, XK_variation}));
keysyms.set(62, new ArrayBox({XK_Shift_R, 0, XK_Shift_R}));
keysyms.set(63, new ArrayBox({XK_KP_Multiply, XK_KP_Multiply, 0, XK_multiply, 0, 0, 0}));
keysyms.set(64, new ArrayBox({XK_Alt_L, XK_Meta_L, XK_Meta_L}));
keysyms.set(65, new ArrayBox({XK_space, XK_space, XK_space, XK_nobreakspace, XK_0, 0, 0}));
keysyms.set(66, new ArrayBox({XK_ISO_Level3_Shift, XK_ISO_Level3_Shift, XK_Caps_Lock, XK_Caps_Lock}));
keysyms.set(67, new ArrayBox({XK_F1, 0, 0}));
keysyms.set(68, new ArrayBox({XK_F2, 0, 0}));
keysyms.set(69, new ArrayBox({XK_F3, 0, 0}));
keysyms.set(70, new ArrayBox({XK_F4, 0, 0}));
keysyms.set(71, new ArrayBox({XK_F5, 0, 0}));
keysyms.set(72, new ArrayBox({XK_F6, 0, 0}));
keysyms.set(73, new ArrayBox({XK_F7, 0, 0}));
keysyms.set(74, new ArrayBox({XK_F8, 0, 0}));
keysyms.set(75, new ArrayBox({XK_F9, 0, 0}));
keysyms.set(76, new ArrayBox({XK_F10, 0, 0}));
keysyms.set(77, new ArrayBox({XK_Tab, XK_ISO_Left_Tab, XK_equal, XK_approxeq, XK_notequal, 0, XK_identical}));
keysyms.set(78, new ArrayBox({XK_Scroll_Lock, 0, XK_Scroll_Lock}));
keysyms.set(79, new ArrayBox({XK_KP_7, 0, 0, 0, XK_KP_Home, XK_KP_Home, 0}));
keysyms.set(80, new ArrayBox({XK_KP_8, 0, XK_uparrow, XK_intersection, XK_KP_Up, XK_KP_Up, 0}));
keysyms.set(81, new ArrayBox({XK_KP_9, XK_KP_9, 0, 0, XK_KP_Prior, XK_KP_Prior, 0}));
keysyms.set(82, new ArrayBox({XK_KP_Subtract, XK_KP_Subtract, 0, 0, 0, 0, 0}));
keysyms.set(83, new ArrayBox({XK_KP_4, 0, XK_leftarrow, XK_includedin, XK_KP_Left, XK_KP_Left, 0}));
keysyms.set(84, new ArrayBox({XK_KP_5, XK_EuroSign, XK_brokenbar, 0, XK_KP_Begin, XK_KP_Begin, 0}));
keysyms.set(85, new ArrayBox({XK_KP_6, XK_KP_6, XK_rightarrow, XK_includes, XK_KP_Right, XK_KP_Right, 0}));
keysyms.set(86, new ArrayBox({XK_KP_Add, XK_KP_Add, XK_plusminus, 0, 0, 0, 0}));
keysyms.set(87, new ArrayBox({XK_KP_1, 0, 0, XK_lessthanequal, XK_KP_End, XK_KP_End, 0}));
keysyms.set(88, new ArrayBox({XK_KP_2, 0, XK_downarrow, XK_union, XK_KP_Down, XK_KP_Down, 0}));
keysyms.set(89, new ArrayBox({XK_KP_3, 0, 0, XK_greaterthanequal, XK_KP_Next, XK_KP_Next, 0}));
keysyms.set(90, new ArrayBox({XK_KP_0, 0, XK_percent, 0, XK_KP_Insert, XK_KP_Insert, 0}));
keysyms.set(91, new ArrayBox({XK_KP_Decimal, XK_comma, XK_period, XK_apostrophe, XK_KP_Delete, XK_KP_Delete, XK_quotedbl}));
keysyms.set(92, new ArrayBox({XK_ISO_Level3_Shift, 0, XK_ISO_Level3_Shift}));
keysyms.set(93, new ArrayBox({XK_Zenkaku_Hankaku, 0, XK_Zenkaku_Hankaku}));
keysyms.set(94, new ArrayBox({XK_ISO_Level5_Shift, 0, XK_ISO_Level5_Shift}));
keysyms.set(95, new ArrayBox({XK_F11, 0, 0}));
keysyms.set(96, new ArrayBox({XK_F12, 0, 0}));
keysyms.set(97, new ArrayBox({}));
keysyms.set(98, new ArrayBox({XK_Katakana, 0, XK_Katakana}));
keysyms.set(99, new ArrayBox({XK_Hiragana, 0, XK_Hiragana}));
keysyms.set(100, new ArrayBox({XK_Henkan_Mode, 0, XK_Henkan_Mode}));
keysyms.set(101, new ArrayBox({XK_Hiragana_Katakana, 0, XK_Hiragana_Katakana}));
keysyms.set(102, new ArrayBox({XK_Muhenkan, 0, XK_Muhenkan}));
keysyms.set(103, new ArrayBox({}));
keysyms.set(104, new ArrayBox({XK_KP_Enter, XK_KP_Enter, XK_KP_Enter, XK_KP_Enter, XK_KP_Enter, XK_KP_Enter, XK_KP_Enter}));
keysyms.set(105, new ArrayBox({XK_Control_R, 0, XK_Control_R}));
keysyms.set(106, new ArrayBox({XK_KP_Divide, XK_KP_Divide, XK_division, 0, 0, 0, 0}));
keysyms.set(107, new ArrayBox({XK_Print, XK_Sys_Req, XK_Sys_Req}));
keysyms.set(108, new ArrayBox({XK_ISO_Level5_Shift, 0, XK_ISO_Level5_Shift}));
keysyms.set(109, new ArrayBox({XK_Linefeed, 0, XK_Linefeed}));
keysyms.set(110, new ArrayBox({XK_Home, 0, XK_Home}));
keysyms.set(111, new ArrayBox({XK_Up, 0, XK_Up}));
keysyms.set(112, new ArrayBox({XK_Prior, 0, XK_Prior}));
keysyms.set(113, new ArrayBox({XK_Left, 0, XK_Left}));
keysyms.set(114, new ArrayBox({XK_Right, 0, XK_Right}));
keysyms.set(115, new ArrayBox({XK_End, 0, XK_End}));
keysyms.set(116, new ArrayBox({XK_Down, 0, XK_Down}));
keysyms.set(117, new ArrayBox({XK_Next, 0, XK_Next}));
keysyms.set(118, new ArrayBox({XK_Insert, 0, XK_Insert}));
keysyms.set(119, new ArrayBox({XK_Delete, 0, XK_Delete}));
keysyms.set(120, new ArrayBox({}));
keysyms.set(121, new ArrayBox({0, 0, 0}));
keysyms.set(122, new ArrayBox({0, 0, 0}));
keysyms.set(123, new ArrayBox({0, 0, 0}));
keysyms.set(124, new ArrayBox({0, 0, 0}));
keysyms.set(125, new ArrayBox({XK_KP_Equal, 0, XK_KP_Equal}));
keysyms.set(126, new ArrayBox({XK_plusminus, 0, XK_plusminus}));
keysyms.set(127, new ArrayBox({XK_Pause, XK_Break, XK_Break}));
keysyms.set(128, new ArrayBox({}));
keysyms.set(129, new ArrayBox({XK_KP_Separator, 0, XK_KP_Separator}));
keysyms.set(130, new ArrayBox({XK_Hangul, 0, XK_Hangul}));
keysyms.set(131, new ArrayBox({XK_Hangul_Hanja, 0, XK_Hangul_Hanja}));
keysyms.set(132, new ArrayBox({}));
keysyms.set(133, new ArrayBox({XK_Super_L, 0, XK_Super_L}));
keysyms.set(134, new ArrayBox({XK_Super_R, 0, XK_Super_R}));
keysyms.set(135, new ArrayBox({XK_Menu, 0, XK_Menu}));
keysyms.set(136, new ArrayBox({XK_Cancel, 0, XK_Cancel}));
keysyms.set(137, new ArrayBox({XK_Redo, 0, XK_Redo}));
keysyms.set(138, new ArrayBox({0, 0, 0}));
keysyms.set(139, new ArrayBox({XK_Undo, 0, XK_Undo}));
keysyms.set(140, new ArrayBox({0, 0, 0}));
keysyms.set(141, new ArrayBox({0, 0, 0}));
keysyms.set(142, new ArrayBox({0, 0, 0}));
keysyms.set(143, new ArrayBox({0, 0, 0}));
keysyms.set(144, new ArrayBox({XK_Find, 0, XK_Find}));
keysyms.set(145, new ArrayBox({0, 0, 0}));
keysyms.set(146, new ArrayBox({XK_Help, 0, XK_Help}));
keysyms.set(147, new ArrayBox({0, 0, 0}));
keysyms.set(148, new ArrayBox({0, 0, 0}));
keysyms.set(149, new ArrayBox({}));
keysyms.set(150, new ArrayBox({0, 0, 0}));
keysyms.set(151, new ArrayBox({0, 0, 0}));
keysyms.set(152, new ArrayBox({0, 0, 0}));
keysyms.set(153, new ArrayBox({0, 0, 0}));
keysyms.set(154, new ArrayBox({}));
keysyms.set(155, new ArrayBox({0, 0, 0}));
keysyms.set(156, new ArrayBox({0, 0, 0}));
keysyms.set(157, new ArrayBox({0, 0, 0}));
keysyms.set(158, new ArrayBox({0, 0, 0}));
keysyms.set(159, new ArrayBox({0, 0, 0}));
keysyms.set(160, new ArrayBox({0, 0, 0}));
keysyms.set(161, new ArrayBox({}));
keysyms.set(162, new ArrayBox({0, 0, 0}));
keysyms.set(163, new ArrayBox({0, 0, 0}));
keysyms.set(164, new ArrayBox({0, 0, 0}));
keysyms.set(165, new ArrayBox({0, 0, 0}));
keysyms.set(166, new ArrayBox({0, 0, 0}));
keysyms.set(167, new ArrayBox({0, 0, 0}));
keysyms.set(168, new ArrayBox({}));
keysyms.set(169, new ArrayBox({0, 0, 0}));
keysyms.set(170, new ArrayBox({0, 0, 0}));
keysyms.set(171, new ArrayBox({0, 0, 0}));
keysyms.set(172, new ArrayBox({0, 0, 0}));
keysyms.set(173, new ArrayBox({0, 0, 0}));
keysyms.set(174, new ArrayBox({0, 0, 0}));
keysyms.set(175, new ArrayBox({0, 0, 0}));
keysyms.set(176, new ArrayBox({0, 0, 0}));
keysyms.set(177, new ArrayBox({0, 0, 0}));
keysyms.set(178, new ArrayBox({}));
keysyms.set(179, new ArrayBox({0, 0, 0}));
keysyms.set(180, new ArrayBox({0, 0, 0}));
keysyms.set(181, new ArrayBox({0, 0, 0}));
keysyms.set(182, new ArrayBox({0, 0, 0}));
keysyms.set(183, new ArrayBox({}));
keysyms.set(184, new ArrayBox({}));
keysyms.set(185, new ArrayBox({0, 0, 0}));
keysyms.set(186, new ArrayBox({0, 0, 0}));
keysyms.set(187, new ArrayBox({XK_parenleft, 0, XK_parenleft}));
keysyms.set(188, new ArrayBox({XK_parenright, 0, XK_parenright}));
keysyms.set(189, new ArrayBox({0, 0, 0}));
keysyms.set(190, new ArrayBox({XK_Redo, 0, XK_Redo}));
keysyms.set(191, new ArrayBox({}));
keysyms.set(192, new ArrayBox({}));
keysyms.set(193, new ArrayBox({}));
keysyms.set(194, new ArrayBox({}));
keysyms.set(195, new ArrayBox({}));
keysyms.set(196, new ArrayBox({}));
keysyms.set(197, new ArrayBox({}));
keysyms.set(198, new ArrayBox({}));
keysyms.set(199, new ArrayBox({}));
keysyms.set(200, new ArrayBox({}));
keysyms.set(201, new ArrayBox({}));
keysyms.set(202, new ArrayBox({}));
keysyms.set(203, new ArrayBox({XK_Mode_switch, 0, XK_Mode_switch}));
keysyms.set(204, new ArrayBox({0, XK_Alt_L, XK_Alt_L}));
keysyms.set(205, new ArrayBox({0, XK_Meta_L, XK_Meta_L}));
keysyms.set(206, new ArrayBox({0, XK_Super_L, XK_Super_L}));
keysyms.set(207, new ArrayBox({0, XK_Hyper_L, XK_Hyper_L}));
keysyms.set(208, new ArrayBox({0, 0, 0}));
keysyms.set(209, new ArrayBox({0, 0, 0}));
keysyms.set(210, new ArrayBox({0, 0, 0}));
keysyms.set(211, new ArrayBox({0, 0, 0}));
keysyms.set(212, new ArrayBox({}));
keysyms.set(213, new ArrayBox({0, 0, 0}));
keysyms.set(214, new ArrayBox({0, 0, 0}));
keysyms.set(215, new ArrayBox({0, 0, 0}));
keysyms.set(216, new ArrayBox({0, 0, 0}));
keysyms.set(217, new ArrayBox({}));
keysyms.set(218, new ArrayBox({XK_Print, 0, XK_Print}));
keysyms.set(219, new ArrayBox({}));
keysyms.set(220, new ArrayBox({0, 0, 0}));
keysyms.set(221, new ArrayBox({}));
keysyms.set(222, new ArrayBox({}));
keysyms.set(223, new ArrayBox({0, 0, 0}));
keysyms.set(224, new ArrayBox({}));
keysyms.set(225, new ArrayBox({0, 0, 0}));
keysyms.set(226, new ArrayBox({}));
keysyms.set(227, new ArrayBox({0, 0, 0}));
keysyms.set(228, new ArrayBox({}));
keysyms.set(229, new ArrayBox({0, 0, 0}));
keysyms.set(230, new ArrayBox({}));
keysyms.set(231, new ArrayBox({XK_Cancel, 0, XK_Cancel}));
keysyms.set(232, new ArrayBox({0, 0, 0}));
keysyms.set(233, new ArrayBox({0, 0, 0}));
keysyms.set(234, new ArrayBox({0, 0, 0}));
keysyms.set(235, new ArrayBox({0, 0, 0}));
keysyms.set(236, new ArrayBox({0, 0, 0}));
keysyms.set(237, new ArrayBox({0, 0, 0}));
keysyms.set(238, new ArrayBox({0, 0, 0}));
keysyms.set(239, new ArrayBox({0, 0, 0}));
keysyms.set(240, new ArrayBox({0, 0, 0}));
keysyms.set(241, new ArrayBox({0, 0, 0}));
keysyms.set(242, new ArrayBox({0, 0, 0}));
keysyms.set(243, new ArrayBox({0, 0, 0}));
keysyms.set(244, new ArrayBox({0, 0, 0}));
keysyms.set(245, new ArrayBox({0, 0, 0}));
keysyms.set(246, new ArrayBox({0, 0, 0}));
keysyms.set(247, new ArrayBox({}));
keysyms.set(248, new ArrayBox({}));
keysyms.set(249, new ArrayBox({}));
keysyms.set(250, new ArrayBox({}));
keysyms.set(251, new ArrayBox({}));
keysyms.set(252, new ArrayBox({}));
keysyms.set(253, new ArrayBox({}));
keysyms.set(254, new ArrayBox({}));
keysyms.set(255, new ArrayBox({}));
return keysyms;
}
public void generateKeyevents() {
HBox[] hboxes = {
new HBox(false, 0),
new HBox(false, 0),
new HBox(false, 0),
new HBox(false, 0),
new HBox(false, 0)
};
this.pack_start( hboxes[0], false, true, 0 );
this.pack_start( hboxes[1], false, true, 0 );
this.pack_start( hboxes[2], false, true, 0 );
this.pack_start( hboxes[3], false, true, 0 );
this.pack_start( hboxes[4], false, true, 0 );
double winWidthUnscaled = 1000.0;
double winHeightUnscaled = 220.0;
if( winMain.config.get("display_numblock")=="0" )
winWidthUnscaled -= winMain.numblock_width;
int width, height;
winMain.get_size2(out width, out height);
double scaleX = width/winWidthUnscaled;
double scaleY = height/winHeightUnscaled;
double posXUnscaled = 0.0;
double posYUnscaled = 0.0;
int posX = 0;
int posY = 0;
GLib.stdout.printf(@"$winWidthUnscaled , $width , $scaleX\n");
//++ Top row ++
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 49, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 10, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 11, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 12, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 13, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 14, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 15, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 16, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 17, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 18, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 19, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 20, false, winMain, hboxes[0], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 21 , false, winMain, hboxes[0], 0);
if( winMain.config.get("display_numblock")!="0" ){
}else{
scaledBox(78.0-1.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 22 , true, winMain, hboxes[0], 0);
}
//Reset right shift.
posXUnscaled = 0.0;
posX = 0;
//++ End top row ++
//++ Second row ++
scaledBox(60.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 23 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 24 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 25 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 26 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 27 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 28 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 29 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 30 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 31 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 32 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 33 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 34 , false, winMain, hboxes[1], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 35 , false, winMain, hboxes[1], 0);
//Halve of Return/Enter
scaledBox(62.0-1,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 36 , true, winMain, hboxes[1], 0);
//Reset right shift.
posXUnscaled = 0.0;
posX = 0;
//++ End second row ++
//++ third row ++
//left mod3
scaledBox(73.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 2/*37*/ , false, winMain, hboxes[2], 1);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 38 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 39 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 40 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 41 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 42 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 43 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 44 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 45 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 46 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 47 , false, winMain, hboxes[2], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 48 , false, winMain, hboxes[2], 0);
//right mod3
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 2/*51*/ , false, winMain, hboxes[2], 1);
//Second halve of Enter/Return
scaledBox(49.0-1,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 36 , true, winMain, hboxes[2], 0);
//Reset right shift.
posXUnscaled = 0.0;
posX = 0;
//++ End third row ++
//++ fourth row ++
//left shift
scaledBox(52.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 1/*50*/ , false, winMain, hboxes[3], 1);
//mod4
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 3/*94*/ , false, winMain, hboxes[3], 1);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 52 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 53 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 54 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 55 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 56 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 57 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 58 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 59 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 60 , false, winMain, hboxes[3], 0);
scaledBox(44.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 61 , false, winMain, hboxes[3], 0);
//right shift
scaledBox(114.0-1,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 1 /*62*/ , true, winMain, hboxes[3], 1);
//Reset right shift.
posXUnscaled = 0.0;
posX = 0;
//++ End fourth row ++
//++ fivth row ++
//left ctrl, 37
scaledBox(61.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 4/*37*/ , false, winMain, hboxes[4], 2);
//free space
scaledBox(48.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , -1 , false, winMain, hboxes[4], 3);
//alt
scaledBox(61.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 5/*64*/ , false, winMain, hboxes[4], 2);
//space
scaledBox(316.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 65 , false, winMain, hboxes[4], 0);
//mod4
scaledBox(61.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 3/*94*/ , false, winMain, hboxes[4], 1);
//free space
scaledBox(40.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , -1 , false, winMain, hboxes[4], 3);
// right ctrl
scaledBox(61.0,44.0,ref posXUnscaled, ref posYUnscaled, ref posX, ref posY, scaleX, scaleY , 4/*105*/ , false, winMain, hboxes[4], 2);
//++ End fivth row ++
}
/*
Gibt scalierte EventBox zurück. Damit sich die Rundungfehler durch int-Cast nicht aufzusummieren,
basieren die Werte auf der bis zu diesem Zeitpunkt zu erwartenden Gesamtbreite/höhe.
*/
private KeyEventBox scaledBox(double widthUnscaled, double heightUnscaled,
ref double posXUnscaled, ref double posYUnscaled,
ref int posX, ref int posY,
double scaleX, double scaleY,
int keycode, bool vertical, NeoWindow winMain, Box box, int boxtype ){
int width = (int) GLib.Math.floor( (posXUnscaled + widthUnscaled)*scaleX - posX ) ;
int height = (int) GLib.Math.floor( (posYUnscaled + heightUnscaled)*scaleY - posY);
if( vertical){
posYUnscaled += heightUnscaled;
posY += height;
}else{
posXUnscaled += widthUnscaled;
posX += width;
}
KeyEventBox keybox;
if( boxtype == 0 ){
// Normale Taste
ArrayBox ks = this.keysyms.get(keycode);
keybox = new KeyEventBox(winMain, width, height, ref ks.val );
this.keyBoxes.set(keycode, keybox);
box.pack_start(keybox, false, true, 0 );
}else if( boxtype == 1){
// Modifier, die andere Buchstabenebenen aktivieren. Zusätzlich Ebenen-Bild einblenden.
keybox = new KeyEventBox.modifier(winMain, width, height, keycode /*=modifier array index*/ );
this.keyBoxes.set(keycode, keybox);
box.pack_start(keybox, false, true, 0 );
}else if( boxtype == 2){
//Andere Modifier (CTRL, Alt,... )
keybox = new KeyEventBox.modifier2(winMain, width, height, keycode /*modifier array index */ );
this.keyBoxes.set(keycode, keybox);
box.pack_start(keybox, false, true, 0 );
}else{
// Fläche ohne Funktion
keybox = new KeyEventBox.freeArea(winMain, width, height );
this.keyBoxes.set(keycode, keybox);
box.pack_start(keybox, false, true, 0 );
}
return keybox;
}
} //End Class KeyOverlay
public class KeyEventBox : EventBox{
//private double widthPercent;
//private double heightPercent;
//static bool flip = true;
private uint[] keysym;// or
private int modifier_index;
private NeoWindow winMain;
private int width;
private int height;
private string cmd;
/*
Die Reihenfolge der Zeichen in keysyms passt nicht
zur Nummerierung der Ebenen in winMain. Mit diesem Array
wird der Wert permutiert.
*/
private static const short[] layer_permutation = {0,1,2,3,5,4,7};
private KeyEventBox.all(NeoWindow winMain, int width, int height){
this.winMain = winMain;
this.width = width;
this.height = height;
/*
if( flip ){
flip = false;
this.set_visible_window(false);
}else{
flip = true;
}
*/
this.set_visible_window(false);
}
public KeyEventBox(NeoWindow winMain, int width, int height , ref uint[] keysym){
//base();
this.all(winMain, width, height);
this.keysym = keysym;
GLib.stdout.printf("Ww: %i, Wh: %i\n", width, height);
this.button_press_event.connect ((event) => {
uint ks = this.keysym[this.layer_permutation[winMain.ebene]-1];
int modi = winMain.active_modifier[4]*winMain.MODIFIER_MASK[4]
+ winMain.active_modifier[5]*winMain.MODIFIER_MASK[5];
if( ks < 1 ) return false;
this.cmd = @"./keysend/keysend $(ks) $(modi)";
GLib.stdout.printf("%s\n", this.cmd);
Posix.system( this.cmd );
return false;
});
}
public KeyEventBox.modifier(NeoWindow winMain, int width, int height , int modifier_index ){
this.all(winMain, width, height);
this.modifier_index = modifier_index;
this.button_press_event.connect ((event) => {
if( winMain.active_modifier[this.modifier_index] == 0){
winMain.active_modifier[this.modifier_index] = 1;
winMain.status.set_label(@"Activate Modifier $(this.modifier_index)");
}else{
winMain.active_modifier[this.modifier_index] = 0;
winMain.status.set_label(@"Deactivate Modifier $(this.modifier_index)");
}
winMain.redraw();
return false;
});
}
public KeyEventBox.modifier2(NeoWindow winMain, int width, int height , int modifier_index ){
this.all(winMain, width, height);
this.modifier_index = modifier_index;
this.button_press_event.connect ((event) => {
if( winMain.active_modifier[this.modifier_index] == 0){
winMain.active_modifier[this.modifier_index] = 1;
//deactivate modifier, which select other charakters
//winMain.active_modifier[0] = 0;//egal
winMain.active_modifier[1] = 0;
winMain.active_modifier[2] = 0;
winMain.active_modifier[3] = 0;
winMain.status.set_label(@"Activate Modifier $(this.modifier_index)");
}else{
winMain.active_modifier[this.modifier_index] = 0;
winMain.status.set_label(@"Deactivate Modifier $(this.modifier_index)");
}
winMain.redraw();
return false;
});
}
public KeyEventBox.freeArea(NeoWindow winMain, int width, int height ){
this.all(winMain, width, height);
}
/*
* This method Gtk+ is calling on a widget to ask
* the widget how large it wishes to be. It's not guaranteed
* that Gtk+ will actually give this size to the widget.
*/
public override void size_request (out Gtk.Requisition requisition) {
//int width, height;
// In this case, we say that we want to be as big as the
// text is, plus a little border around it.
//this.layout.get_size (out width, out height);
requisition.width = width ;// / Pango.SCALE;
requisition.height = height; // / Pango.SCALE;
GLib.stdout.printf("W: %i, H: %i, Sc: %f\n",width, height, Pango.SCALE);
}
}
}

310
keybinding-manager.vala

@ -0,0 +1,310 @@
namespace NeoLayoutViewer{
/**
* Modification of http://www.linux-nantes.org/~fmonnier/ocaml/Xlib/doc/Xlib.html by
* Oliver Sauder <os@esite.ch>
*/
public class KeybindingManager : GLib.Object
{
private NeoWindow neo_win;
/**
* list of binded keybindings
*/
private Gee.List<Keybinding> bindings = new Gee.ArrayList<Keybinding>();
private Gee.List<ModifierKeybinding> modifier_bindings = new Gee.ArrayList<ModifierKeybinding>();
/**
* locked modifiers used to grab all keys whatever lock key
* is pressed.
*/
private static uint[] lock_modifiers = {
0,
Gdk.ModifierType.MOD2_MASK, // NUM_LOCK
Gdk.ModifierType.LOCK_MASK, // CAPS_LOCK
Gdk.ModifierType.MOD5_MASK, // SCROLL_LOCK
Gdk.ModifierType.MOD2_MASK|Gdk.ModifierType.LOCK_MASK,
Gdk.ModifierType.MOD2_MASK|Gdk.ModifierType.MOD5_MASK,
Gdk.ModifierType.LOCK_MASK|Gdk.ModifierType.MOD5_MASK,
Gdk.ModifierType.MOD2_MASK|Gdk.ModifierType.LOCK_MASK|Gdk.ModifierType.MOD5_MASK
};
/**
* Helper class to store keybinding
*/
private class Keybinding
{
public Keybinding(string accelerator, int keycode,
Gdk.ModifierType modifiers, KeybindingHandlerFunc handler)
{
this.accelerator = accelerator;
this.keycode = keycode;
this.modifiers = modifiers;
this.handler = handler;
}
public string accelerator { get; set; }
public int keycode { get; set; }
public Gdk.ModifierType modifiers { get; set; }
public KeybindingHandlerFunc handler { get; set; }
}
/**
* Helper class to store second set of keybindings (modifier)
*/
private class ModifierKeybinding
{
public ModifierKeybinding(string accelerator, int keycode,
Gdk.ModifierType modifiers, int ebene, KeybindingHandlerFunc handler)
{
this.accelerator = accelerator;
this.keycode = keycode;
this.ebene = ebene;
this.modifiers = modifiers;
this.handler = handler;
}
public string accelerator { get; set; }
public int keycode { get; set; }
public int ebene { get; set; }
public Gdk.ModifierType modifiers { get; set; }
public KeybindingHandlerFunc handler { get; set; }
}
/**
* Keybinding func needed to bind key to handler
*
* @param event passing on gdk event
*/
public delegate void KeybindingHandlerFunc(Gdk.Event event);
public KeybindingManager(NeoWindow neo_win)
{
this.neo_win = neo_win;
// init filter to retrieve X.Events
Gdk.Window rootwin = Gdk.get_default_root_window();
if(rootwin != null) {
rootwin.add_filter(event_filter);
}
//some tests
/*
X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ModifierKeymap modmap = display.get_modifier_mapping ();
debug("Max mod: %i\n".printf(modmap.max_keypermod));
for(int i=0; i<modmap.max_keypermod;i++){
debug(modmap.modifiermap[i].to_string()+"\n");
}*/
}
/**
* Bind accelerator to given handler
*
* @param accelerator accelerator parsable by Gtk.accelerator_parse
* @param handler handler called when given accelerator is pressed
*/
public void bind(string accelerator, KeybindingHandlerFunc handler)
{
//debug("Binding key " + accelerator);
// convert accelerator
uint keysym;
Gdk.ModifierType modifiers;
Gtk.accelerator_parse(accelerator, out keysym, out modifiers);
Gdk.Window rootwin = Gdk.get_default_root_window();
unowned X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ID xid = Gdk.x11_drawable_get_xid(rootwin);
int keycode = display.keysym_to_keycode(keysym);
if(keycode != 0) {
// trap XErrors to avoid closing of application
// even when grabing of key fails
Gdk.error_trap_push();
// grab key finally
// also grab all keys which are combined with a lock key such NumLock
foreach(uint lock_modifier in lock_modifiers) {
display.grab_key(keycode, modifiers|lock_modifier, xid, false, X.GrabMode.Async, X.GrabMode.Async);
}
// wait until all X request have been processed
Gdk.flush();
// store binding
Keybinding binding = new Keybinding(accelerator, keycode, modifiers, handler);
bindings.add(binding);
//debug("Successfully binded key " + accelerator);
}
}
public void bind2(int keycode, string accelerator, int ebene, KeybindingHandlerFunc handler)
{
// convert accelerator
/*uint keysym;
Gdk.ModifierType modifiers;
Gtk.accelerator_parse(accelerator, out keysym, out modifiers);*/
Gdk.Window rootwin = Gdk.get_default_root_window();
unowned X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ID xid = Gdk.x11_drawable_get_xid(rootwin);
//int keycode = display.keysym_to_keycode(keysym);
if(keycode != 0) {
// trap XErrors to avoid closing of application
// even when grabing of key fails
Gdk.error_trap_push();
// grab key finally
display.grab_key(keycode, 0, xid, false, X.GrabMode.Async, X.GrabMode.Async);
// wait until all X request have been processed
Gdk.flush();
// store binding
ModifierKeybinding binding = new ModifierKeybinding(accelerator, keycode, 0, ebene, handler);
modifier_bindings.add(binding);
//debug("Successfully binded key ");
}
}
/**
* Unbind given accelerator.
*
* @param accelerator accelerator parsable by Gtk.accelerator_parse
*/
public void unbind(string accelerator)
{
//debug("Unbinding key " + accelerator);
Gdk.Window rootwin = Gdk.get_default_root_window();
unowned X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ID xid = Gdk.x11_drawable_get_xid(rootwin);
// unbind all keys with given accelerator
Gee.List<Keybinding> remove_bindings = new Gee.ArrayList<Keybinding>();
foreach(Keybinding binding in bindings) {
if(str_equal(accelerator, binding.accelerator)) {
foreach(uint lock_modifier in lock_modifiers) {
display.ungrab_key(binding.keycode, binding.modifiers, xid);
}
remove_bindings.add(binding);
}
}
// remove unbinded keys
bindings.remove_all(remove_bindings);
}
public void unbind2(int keycode)
{
//debug("Unbinding key\n ");
Gdk.Window rootwin = Gdk.get_default_root_window();
unowned X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ID xid = Gdk.x11_drawable_get_xid(rootwin);
// unbind all keys with given accelerator
Gee.List<ModifierKeybinding> remove_bindings = new Gee.ArrayList<ModifierKeybinding>();
foreach(ModifierKeybinding binding in modifier_bindings) {
if(keycode == binding.keycode) {
display.ungrab_key(binding.keycode, binding.modifiers, xid);
remove_bindings.add(binding);
}
}
// remove unbinded keys
bindings.remove_all(remove_bindings);
}
/**
* Event filter method needed to fetch X.Events
*/
public Gdk.FilterReturn event_filter(Gdk.XEvent gdk_xevent, Gdk.Event gdk_event)
{
Gdk.FilterReturn filter_return = Gdk.FilterReturn.CONTINUE;
//Gdk.FilterReturn filter_return = Gdk.FilterReturn.REMOVE;
void* pointer = &gdk_xevent;
X.Event* xevent = (X.Event*) pointer;
if(xevent->type == X.EventType.KeyPress) {
foreach(Keybinding binding in bindings) {
// remove NumLock, CapsLock and ScrollLock from key state
uint event_mods = xevent.xkey.state & ~ (lock_modifiers[7]);
if(xevent->xkey.keycode == binding.keycode && event_mods == binding.modifiers) {
// call all handlers with pressed key and modifiers
binding.handler(gdk_event);
}
}
}
if(xevent->type == X.EventType.KeyPress) {
uint event_mods = xevent.xkey.state;
foreach(ModifierKeybinding binding in modifier_bindings) {
if(xevent->xkey.keycode == binding.keycode) {
//neo_win.external_key_press(binding.ebene,(int)event_mods);
neo_win.active_modifier[binding.ebene] = 1;
neo_win.redraw();
// call all handlers with pressed key and modifiers
binding.handler(gdk_event);
//send_event_again(Gdk.get_default_root_window(), binding, *xevent);
}
}
}
if(xevent->type == X.EventType.KeyRelease) {
uint event_mods = xevent.xkey.state;
foreach(ModifierKeybinding binding in modifier_bindings) {
if(xevent->xkey.keycode == binding.keycode) {
//neo_win.external_key_release(0,(int)event_mods);
neo_win.active_modifier[binding.ebene] = 0;
neo_win.redraw();
// call all handlers with pressed key and modifiers
binding.handler(gdk_event);
//send_event_again(Gdk.get_default_root_window(), binding, *xevent);
}
}
}
debug("Filter %u\n".printf(xevent.xkey.keycode));
send_event_again(Gdk.get_default_root_window(), *xevent);
return filter_return;
}
private void send_event_again(Gdk.Window rootwin, X.Event xevent){
if(rootwin != null) {
unowned X.Display display = Gdk.x11_drawable_get_xdisplay(rootwin);
X.ID xid = Gdk.x11_drawable_get_xid(rootwin);
foreach(ModifierKeybinding binding in modifier_bindings){
display.ungrab_key(binding.keycode, binding.modifiers, xid);
}
//rootwin.remove_filter(event_filter);
debug("Send Event again %u\n".printf(xevent.xkey.state));
display.send_event(xevent.xkey.window,true,xevent.xkey.state,ref xevent);
//rootwin.add_filter(event_filter);
foreach(ModifierKeybinding binding in modifier_bindings){
// display.grab_key(binding.keycode, 0, xid, false, X.GrabMode.Async, X.GrabMode.Async);
}
}
}
}
}

435
neo2.vala

@ -0,0 +1,435 @@
using Gtk;
using Gdk;
using X; //keysym.h
using Posix;//system-calls
namespace NeoLayoutViewer{
public class NeoWindow : Gtk.Window {
private Gtk.Image image;
public Gtk.Label status;
private Gdk.Pixbuf[] image_buffer;
public Gee.HashMap<string, string> config;
public int ebene;
public int[] active_modifier;
public int numblock_width;
//private Button button;
private bool minimized;
private int position_num;
private int[] position_cycle;
/* Die Neo-Modifier unterscheiden sich zum Teil von den Normalen, für die Konstanten definiert sind. Bei der Initialisierung werden aus den Standardkonstanen die Konstenen für die Ebenen 1-6 berechnet.*/
public int[] NEO_MODIFIER_MASK;
public int[] MODIFIER_MASK;
// /* Modifier-codes für CTLR, ALT, ... */
// public int[] OTHER_MODIFIER_MASK;
/* Die Keycodes von ShiftL, ShiftR, Mod3 (Alt Gr,<) und Mod4 (CapsLock, #)... in der Uni schon mal keine Übereinstimmung*/
//private int[] MODIFIER_KEY_CODES = {65505,65506,65027,65041};//home
//private int[] MODIFIER_KEY_CODES = {65505,65506,65406,65027};//uni
/* Falls ein Modifier (oder eine andere Taste) gedrückt wird und schon Modifier gedrückt sind, gibt die Map an, welche Ebene dann aktiviert ist. */
private short[,] MODIFIER_MAP = {
{0,1,2,3,4,5},
{1,1,4,3,4,5},
{2,4,2,5,4,5},
{3,3,5,3,4,5} };
/* [0,1]^3->{0,5}, Bildet aktive Modifier auf angezeigte Ebene ab.
Interpretationsreihenfolge der Dimensionen: Shift,Neo-Mod3, Neo-Mod4. */
private short[,,] MODIFIER_MAP2 = {
{ {0 , 3}, {2 , 5 } }, // 000, 001; 010, 011
{ {1 , 3}, {4 , 5}} // 100, 101; 110, 111
};
/* Analog zu oben für den Fall, dass eine Taste losgelassen wird. Funktioniert nicht immer.
Ist beispielsweise ShiftL und ShiftR gedrückt und eine wird losgelassen, so wechelt die Anzeige zur ersten Ebene.
Die Fehler sind imo zu vernachlässigen.
*/
private short[,] MODIFIER_MAP_RELEASE = {
{0,0,0,0,0,0},
{0,0,2,3,2,5},
{0,1,0,3,1,3},
{0,1,2,0,4,2} };
public NeoWindow (string sebene, Gee.HashMap<string, string> config) {
this.config = config;
this.minimized = true;
this.NEO_MODIFIER_MASK = {
0,
Gdk.ModifierType.SHIFT_MASK, //1
Gdk.ModifierType.MOD5_MASK+Gdk.ModifierType.LOCK_MASK, //128+2
Gdk.ModifierType.MOD3_MASK, //32
Gdk.ModifierType.MOD5_MASK+Gdk.ModifierType.LOCK_MASK+Gdk.ModifierType.SHIFT_MASK, //128+2+1
Gdk.ModifierType.MOD5_MASK+Gdk.ModifierType.LOCK_MASK+Gdk.ModifierType.MOD3_MASK //128+2+32
};
/*
this.OTHER_MODIFIER_MASK = {
Gdk.ModifierType.CONTROL_MASK,
Gdk.ModifierType.MOD1_MASK
};*/
this.MODIFIER_MASK = {
0,
Gdk.ModifierType.SHIFT_MASK, //1
Gdk.ModifierType.MOD5_MASK,//128
Gdk.ModifierType.MOD3_MASK, //32
Gdk.ModifierType.CONTROL_MASK,
Gdk.ModifierType.MOD1_MASK // Alt-Mask do not work :-(
};
this.active_modifier = {0,0,0,0,0,0};
this.position_num = int.max(int.min(int.parse(config.get("position")),9),1);
//Anlegen des Arrays, welches den Positionsdurchlauf beschreibt.
try{
var space = new Regex(" ");
string[] split = space.split(config.get("position_cycle"));
position_cycle = new int[int.max(9,split.length)];
for(int i=0;i<split.length;i++){
position_cycle[i] = int.max(int.min(int.parse(split[i]),9),1);//Zulässiger Bereich: 1-9
}
} catch (RegexError e) {
position_cycle = {3,3,9,1,3,9,1,7,7};
}
this.ebene = int.parse(sebene);
if(this.ebene<1 || this.ebene>6) {this.ebene = 1; }
//Lade die Pngs der sechs Ebenen
this.load_image_buffer();
this.image = new Gtk.Image();//.from_pixbuf(this.image_buffer[ebene]);
// Create an image and render first page to image
//var pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, false, 8, 800, 600);
render_page ();
var fixed = new Fixed();
add(fixed);
fixed.put(this.image, 0, 0);
fixed.put( new KeyOverlay(this) , 0, 0);
this.status = new Label("");
fixed.put( status, 2, 2 );
//Fenstereigenschaften setzen
this.key_press_event.connect (on_key_pressed);
this.destroy.connect (Gtk.main_quit);
this.set_gravity(Gdk.Gravity.SOUTH);
//this.move(-100,-100);
/*GdkGeometry size_hints = {
100, 50, 0, 0, 100, 50, 10, 10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
};
gtk_window_set_geometry_hints (GTK_WINDOW (this), this, &size_hints,
GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC);
*/
//this.window_position = WindowPosition.CENTER;
//this.default_height = int.parse( config.get("height") );
//this.default_width = int.parse( config.get("width") );
this.decorated = false;
//this.allow_grow = false;
//this.allow_shrink = false;
this.skip_taskbar_hint = true;
this.show_all();
//Move ist erst nach show_all() erfolgreich
this.numkeypad_move(int.parse(config.get("position")));
//Icon des Fensters
this.icon = this.image_buffer[0];
//Nicht selektierbar (für virtuelle Tastatur)
this.set_accept_focus(false);
}
public override void show_all(){
this.minimized = false;
base.show_all();
//this.present();
//set_visible(true);
this.numkeypad_move(this.position_num);
if( config.get("on_top")=="1")
this.set_keep_above(true);
else
this.present();
}
public override void hide_all(){
this.minimized = true;
base.hide_all();
//set_visible(false);
}
public bool toggle(){
if(this.minimized) show_all();
else hide_all();
return this.minimized;
}
/* Falsche Werte bei „Tiled Window Managern“. */
public void get_size2(out int width, out int height){
width = this.image_buffer[1].width;
height = this.image_buffer[1].height;
}
public void numkeypad_move(int pos){
int screen_width = this.screen.width();
int screen_height = this.screen.height();
int x,y,w,h;
this.get_size(out w,out h);
switch (pos){
case 0: //Zur nächsten Position wechseln
numkeypad_move(this.position_cycle[this.position_num-1]);
return;
case 7:
x = 0;
y = 0;
break;
case 8:
x = (screen_width-w)/2;
y = 0;
break;
case 9:
x = screen_width-w;
y = 0;
break;
case 4:
x = 0;
y = (screen_height-h)/2;
break;
case 5:
x = (screen_width-w)/2;
y = (screen_height-h)/2;
break;
case 6:
x = screen_width-w;
y = (screen_height-h)/2;
break;
case 1:
x = 0;
y = screen_height-h;
break;
case 2:
x = (screen_width-w)/2;
y = screen_height-h;
break;
//case 3: //=default case
// ;
default:
x = screen_width-w;
y = screen_height-h;
break;
}
this.position_num = pos;
this.move(x,y);
}
public Gdk.Pixbuf open_image (int ebene) {
var bildpfad = "assets/neo2.1/tastatur_neo_Ebene%i.png".printf(ebene);
return open_image_str(bildpfad);
//return new Image_from_pixpuf(open_image_str(bildpfad));
}
public Gdk.Pixbuf open_image_str (string bildpfad) {
try {
return new Gdk.Pixbuf.from_file (bildpfad);
} catch (Error e) {
error ("%s", e.message);
}
}
public void load_image_buffer () {
this.image_buffer = new Gdk.Pixbuf[7];
this.image_buffer[0] = open_image_str("assets/icons/Neo-Icon.png");
int screen_width = this.screen.width();
//int screen_height = this.screen.height();
int max_width = (int) ( double.parse( this.config.get("max_width") )*screen_width );
int min_width = (int) ( double.parse( this.config.get("min_width") )*screen_width );
int width = int.min(int.max(int.parse( config.get("width") ),min_width),max_width);
int w,h;
for (int i=1; i<7; i++){
this.image_buffer[i] = open_image(i);
//Numpad-Teil abschneiden, falls gefordert
this.numblock_width = int.parse(config.get("numblock_width"));
if( config.get("display_numblock")=="0" ){
var tmp = new Gdk.Pixbuf(image_buffer[i].colorspace,image_buffer[i].has_alpha,image_buffer[i].bits_per_sample, image_buffer[i].width-numblock_width ,image_buffer[i].height);
this.image_buffer[i].copy_area(0,0,tmp.width,tmp.height,tmp,0,0);
this.image_buffer[i] = tmp;
}
//Bilder einmaling beim Laden skalieren. (Keine spätere Skalierung durch Größenänderung des Fensters)
w = this.image_buffer[i].width;
h = this.image_buffer[i].height;
this.image_buffer[i] = this.image_buffer[i].scale_simple(width, h*width/w,Gdk.InterpType.BILINEAR);
}
}
private bool on_key_pressed (Widget source, Gdk.EventKey key) {
// If the key pressed was q, quit, else show the next page
if (key.str == "q") {
Gtk.main_quit ();
}
if (key.str == "h") {
this.hide_all();
}
/* Erste Auswahlvariante: Zahlen 1-6 */
var ebene_tmp = int.parse(key.str);
if(ebene_tmp>0 && ebene_tmp<7) {
if(this.ebene != ebene_tmp){
this.ebene = ebene_tmp;
render_page ();
}
}
/*else{
//Finde die aktuelle Taste und die derzeit gedrückten Modifier
int iet1 = 0;
int iet2 = 0;
debug("%u".printf(key.keyval));
if( key.keyval == MODIFIER_KEY_CODES[0] || key.keyval == MODIFIER_KEY_CODES[1]){
iet1=1;
}else if( key.keyval == MODIFIER_KEY_CODES[2]){
iet1=2;
}else if( key.keyval == MODIFIER_KEY_CODES[3]){
iet1=3;
}
for(int i=0; i<6; i++){
if( key.state == NEO_MODIFIER_MASK[i]){
iet2=i;
break;
}
}
iet1 = this.MODIFIER_MAP[iet1,iet2]+1;
check_modifier(iet1);
}*/
/*
stdout.printf("Aktuell: %i \nModifierids: %i %i %i %i\n %i %i %i %i \n %i %i %i %i %i\n\n",
key.state, Gdk.ModifierType.SHIFT_MASK, Gdk.ModifierType.LOCK_MASK, Gdk.ModifierType.CONTROL_MASK, Gdk.ModifierType.SUPER_MASK, Gdk.ModifierType.HYPER_MASK, Gdk.ModifierType.META_MASK, Gdk.ModifierType.RELEASE_MASK, Gdk.ModifierType.MODIFIER_MASK, Gdk.ModifierType.MOD1_MASK, Gdk.ModifierType.MOD2_MASK, Gdk.ModifierType.MOD3_MASK, Gdk.ModifierType.MOD4_MASK, Gdk.ModifierType.MOD5_MASK);*/
return false;
}
private void check_modifier(int iet1){
if(iet1 != this.ebene){
this.ebene = iet1;
render_page ();
}
}
public void redraw(){
this.ebene = this.MODIFIER_MAP2[
this.active_modifier[1], //shift
this.active_modifier[2], //neo-mod3
this.active_modifier[3] //neo-mod4
] + 1;
render_page();
}
private void render_page () {
this.image.set_from_pixbuf(this.image_buffer[this.ebene]);
}
public Gdk.Pixbuf getIcon(){
return this.image_buffer[0];
}
public void external_key_press(int iet1, int modifier_mask){
for(int iet2=0; iet2<4; iet2++){
if(this.NEO_MODIFIER_MASK[iet2]==modifier_mask){
//debug("(Press) e1=%i, e2=%i\n".printf(iet1,iet2));
iet1 = this.MODIFIER_MAP[iet1,iet2]+1;
this.check_modifier(iet1);
return;
}
}
iet1 = this.MODIFIER_MAP[iet1,0]+1;
this.check_modifier(iet1);
}
public void external_key_release(int iet1, int modifier_mask){
for(int iet2=0; iet2<4; iet2++){
if(this.NEO_MODIFIER_MASK[iet2]==modifier_mask){
//debug("(Relase) e1=%i, e2=%i\n\n".printf(iet1,iet2));
iet1 = this.MODIFIER_MAP_RELEASE[iet1,iet2]+1;
this.check_modifier(iet1);
return;
}
}
iet1 = this.MODIFIER_MAP_RELEASE[iet1,0]+1;
this.check_modifier(iet1);
}
/*public void updateLayer(int iet){
if( 0<iet && iet<7 && this.ebene==iet){
this.ebene = iet;
render_page();
}
}*/
public static int main (string[] args) {
string sebene;
if( args.length<2) {
sebene="1";
}else{
sebene=args[1];
}
Gtk.init (ref args);
var configm = new ConfigManager("neolayoutviewer.conf");
var neo_win = new NeoWindow (sebene, configm.getConfig());
var neo_tray = new AppStatusIcon(neo_win);
var manager = new KeybindingManager(neo_win);
manager.bind2(50, "ShiftL",1, ()=>{});
manager.bind2(62, "ShiftR",1, ()=>{});
manager.bind2(66, "Mod3L",2, ()=>{});
manager.bind2(51, "Mod3R",2, ()=>{});
manager.bind2(94, "Mod4",3, ()=>{});
manager.bind2(108, "Mod4",3, ()=>{});
manager.bind(configm.getConfig().get("show_shortcut"), ()=>{neo_win.toggle();});
manager.bind(configm.getConfig().get("move_shortcut"), ()=>{neo_win.numkeypad_move(0);});
//neo_win.show_all ();
//neo_win.hide_all();
//move window (Fehlerquelle: config von configm, nicht neo_win. Derzeit gleiches Objekt.)
Gtk.main ();
manager.unbind2(50);
manager.unbind2(62);
manager.unbind2(66);
manager.unbind2(51);
manager.unbind2(94);
manager.unbind2(108);
return 0;
}
} //End class NeoWindow
}

60
tray.vala

@ -0,0 +1,60 @@
using Gtk;
namespace NeoLayoutViewer{
class AppStatusIcon {
public StatusIcon trayicon;
private Menu menuMain;
private NeoWindow neo_win;
public AppStatusIcon(NeoWindow neo_win) {
this.neo_win = neo_win;
/* Create tray icon */
//trayicon = new StatusIcon.from_stock(Stock.HOME);
//trayicon = new StatusIcon.from_file("Neo-Icon.png");
trayicon = new StatusIcon.from_pixbuf(neo_win.get_icon());
trayicon.set_tooltip_text ("Neo 2.0 Layout Viewer");
trayicon.set_visible(true);
create_menuMain();
/* Connect popup_menu with right click */
trayicon.popup_menu.connect(menuMain_popup);
/* Connect main window with left click/acitvation */
//trayicon.activate.connect(this.neo_win.show_all);
trayicon.activate.connect(()=>{this.neo_win.toggle();});
}
/* Create popup menu */
public void create_menuMain() {
menuMain = new Menu();
var menuAbout = new ImageMenuItem.from_stock(Stock.ABOUT, null);
menuAbout.activate.connect(about_clicked);
menuMain.append(menuAbout);
var menuQuit = new ImageMenuItem.from_stock(Stock.QUIT, null);
menuQuit.activate.connect(Gtk.main_quit);
menuMain.append(menuQuit);
menuMain.show_all();
}
/* Show popup menu on right button */
private void menuMain_popup(uint button, uint time) {
menuMain.popup(null, null, null, button, time);
}
private void about_clicked() {
var about = new AboutDialog();
about.set_version("0.0.1");
about.set_program_name("Neo2.0 Ebenenanzeige");
about.set_comments("Erleichtert das Nachschlagen von Tastenkombinationen.\n\n Olaf Schulz\n schulz-AT-math.hu-berlin.de ");
about.set_copyright("GPLv?");
about.run();
about.hide();
}
}
}

8289
vapi/gtk+-2.0.vapi
File diff suppressed because it is too large
View File

4
vapi/gtk+-2.0.vapi.diff

@ -0,0 +1,4 @@
4182c4182
< public weak GLib.List children;
---
> public weak GLib.List<TableChild> children;

56
vapi/keysym.vapi

@ -0,0 +1,56 @@
/* keysym.vapi generated by valac 0.13.1, do not modify. */
[CCode (cprefix = "NeoLayoutViewer", lower_case_cprefix = "neo_layout_viewer_")]
namespace NeoLayoutViewer {
[CCode (cheader_filename = "neo2.h")]
public class KeyEventBox : Gtk.EventBox {
public KeyEventBox (NeoLayoutViewer.NeoWindow winMain, int width, int height, ref uint[] keysym);
public KeyEventBox.freeArea (NeoLayoutViewer.NeoWindow winMain, int width, int height);
public KeyEventBox.modifier (NeoLayoutViewer.NeoWindow winMain, int width, int height, int modifier_index);
public KeyEventBox.modifier2 (NeoLayoutViewer.NeoWindow winMain, int width, int height, int modifier_index);
public override void size_request (out Gtk.Requisition requisition);
}
[CCode (cheader_filename = "neo2.h")]
public class KeyOverlay : Gtk.VBox {
public Gee.HashMap<int,NeoLayoutViewer.KeyEventBox> keyBoxes;
public Gee.HashMap<int,NeoLayoutViewer.ArrayBox> keysyms;
public KeyOverlay (NeoLayoutViewer.NeoWindow winMain);
public void generateKeyevents ();
public Gee.HashMap<int,NeoLayoutViewer.ArrayBox> generateKeysyms ();
}
[CCode (cheader_filename = "neo2.h")]
public class KeybindingManager : GLib.Object {
[CCode (cheader_filename = "neo2.h")]
public delegate void KeybindingHandlerFunc (Gdk.Event event);
public KeybindingManager (NeoLayoutViewer.NeoWindow neo_win);
public void bind (string accelerator, NeoLayoutViewer.KeybindingManager.KeybindingHandlerFunc handler);
public void bind2 (int keycode, string accelerator, int ebene, NeoLayoutViewer.KeybindingManager.KeybindingHandlerFunc handler);
public Gdk.FilterReturn event_filter (Gdk.XEvent gdk_xevent, Gdk.Event gdk_event);
public void unbind (string accelerator);
public void unbind2 (int keycode);
}
[CCode (cheader_filename = "neo2.h")]
public class NeoWindow : Gtk.Window {
public int[] MODIFIER_MASK;
public int[] NEO_MODIFIER_MASK;
public int[] active_modifier;
public Gee.HashMap<string,string> config;
public int ebene;
public int numblock_width;
public Gtk.Label status;
public NeoWindow (string sebene, Gee.HashMap<string,string> config);
public void external_key_press (int iet1, int modifier_mask);
public void external_key_release (int iet1, int modifier_mask);
public Gdk.Pixbuf getIcon ();
public void get_size2 (out int width, out int height);
public override void hide_all ();
public void load_image_buffer ();
public static int main (string[] args);
public void numkeypad_move (int pos);
public Gdk.Pixbuf open_image (int ebene);
public Gdk.Pixbuf open_image_str (string bildpfad);
public void redraw ();
public override void show_all ();
public bool toggle ();
}
}
Loading…
Cancel
Save