X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=9d02c4a70f4a1698124263f55414969573489f54;hb=aab3c89d03c1a99cb91ff1870775b2c44806bb79;hp=32cd87940fe22e71abcef2769f2c3b6516181005;hpb=a38c924ff32081f5cd67c2b0e2d5ca61f0e99de2;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index 32cd879..9d02c4a 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,9 +1,17 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + +#include #include "root.h" namespace Msp { namespace GLtk { -Root::Root(Resources &r, Window &w): +Root::Root(const Resources &r, Graphics::Window &w): Panel(r), window(w) { @@ -14,24 +22,47 @@ Root::Root(Resources &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_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)