diff --git a/src/main_window.cc b/src/main_window.cc index 93e159f..066e09c 100644 --- a/src/main_window.cc +++ b/src/main_window.cc @@ -39,9 +39,13 @@ main_window::main_window() void main_window::connect_all() { + (*this).add_events( Gdk::BUTTON_PRESS_MASK ) ; log_debug("connecting all"); - (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event)); - (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event)); +// (*this).press_id = signal_key_press_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_press_event)); +// (*this).release_id = signal_key_release_event().connect(sigc::mem_fun(*this,&main_window::on_my_key_release_event)); +// (*this).press_id = + (*this).press_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_press_event)); + (*this).release_id = (*this).signal_key_press_event().connect_notify(sigc::mem_fun(*this,&main_window::on_notify_key_release_event)); log_debug((*this).press_id << " " << (*this).release_id); } @@ -64,6 +68,11 @@ bool main_window::actions(int key) static int key_s = 115; static int key_t = 116; static int key_f1 = 65470; + static int left = 65361; + static int top = 65362; + static int right = 65363; + static int bottom = 65364; + // key commands only available if ctrl pressed if ((ctrl_state == 1) && ((*this).press_id == 1)) @@ -106,8 +115,9 @@ bool main_window::actions(int key) } -bool main_window::on_my_key_press_event(GdkEventKey *Key) +void main_window::on_notify_key_press_event(GdkEventKey *Key) { + if (Key->keyval == gdk_keyval_from_name("Control_R")) { ctrl_state = 1; @@ -116,20 +126,42 @@ bool main_window::on_my_key_press_event(GdkEventKey *Key) { actions(Key->keyval); } -// log_debug("Key Presssed is " << Key->keyval); - return true; + log_debug("Key Presssed is " << Key->keyval); } -bool main_window::on_my_key_release_event(GdkEventKey *Key) +void main_window::on_notify_key_release_event(GdkEventKey *Key) { if (Key->keyval == gdk_keyval_from_name("Control_R")) { ctrl_state = 0; } - return true; } +// bool main_window::on_my_key_press_event(GdkEventKey *Key) +// { +// if (Key->keyval == gdk_keyval_from_name("Control_R")) +// { +// ctrl_state = 1; +// } +// else +// { +// actions(Key->keyval); +// } +// log_debug("Key Presssed is " << Key->keyval); +// return true; +// } + +// bool main_window::on_my_key_release_event(GdkEventKey *Key) +// { +// if (Key->keyval == gdk_keyval_from_name("Control_R")) +// { +// ctrl_state = 0; +// } +// +// return true; +// } + bool main_window::quit() { hide(); diff --git a/src/main_window.hh b/src/main_window.hh index cc20ae2..06e4786 100644 --- a/src/main_window.hh +++ b/src/main_window.hh @@ -35,8 +35,10 @@ class main_window : public Gtk::Window private: bool actions(int); int ctrl_state; - bool on_my_key_press_event(GdkEventKey *event); - bool on_my_key_release_event(GdkEventKey *event); +// bool on_my_key_press_event(GdkEventKey *event); + void on_notify_key_press_event(GdkEventKey *event); + void on_notify_key_release_event(GdkEventKey *event); +// bool on_my_key_release_event(GdkEventKey *event); bool quit(); };