/* $Id$
This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
+Copyright © 2007-2009 Mikko Rasa, Mikkosoft Productions
Distributed under the LGPL
*/
+#include <msp/input/keys.h>
#include "root.h"
namespace Msp {
namespace GLtk {
-Root::Root(Resources &r, Window &w):
+Root::Root(const Resources &r, Graphics::Window &w):
+ Widget(r),
Panel(r),
window(w)
{
window.signal_button_press.connect(sigc::mem_fun(this, &Root::button_press_event));
window.signal_button_release.connect(sigc::mem_fun(this, &Root::button_release_event));
window.signal_pointer_motion.connect(sigc::mem_fun(this, &Root::pointer_motion_event));
- window.signal_key_press.connect(sigc::mem_fun(this, &Root::key_press));
- window.signal_key_release.connect(sigc::mem_fun(this, &Root::key_release));
+ window.signal_key_press.connect(sigc::mem_fun(this, &Root::key_press_event));
+ window.signal_key_release.connect(sigc::mem_fun(this, &Root::key_release_event));
}
void Root::button_press_event(int x, int y, unsigned btn, unsigned)
{
- translate_coords(x, y);
- button_press(x, y, btn);
+ if(visible)
+ {
+ translate_coords(x, y);
+ button_press(x, y, btn);
+ }
}
void Root::button_release_event(int x, int y, unsigned btn, unsigned)
{
- translate_coords(x, y);
- button_release(x, y, btn);
+ if(visible)
+ {
+ translate_coords(x, y);
+ button_release(x, y, btn);
+ }
}
void Root::pointer_motion_event(int x, int y)
{
- translate_coords(x, y);
- pointer_motion(x, y);
+ if(visible)
+ {
+ translate_coords(x, y);
+ pointer_motion(x, y);
+ }
+}
+
+void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch)
+{
+ if(visible)
+ key_press(Input::key_from_sys(key), mod, ch);
+}
+
+void Root::key_release_event(unsigned key, unsigned mod)
+{
+ if(visible)
+ key_release(Input::key_from_sys(key), mod);
}
void Root::translate_coords(int &x, int &y)