X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=a59c939b5b1415d1e918c7fe7c7a023652303ee6;hb=c2635c5a3dca6a6cea5562fd387beb0662b18cf0;hp=83042a63f3c8a62339d40b7ae5708306fef398da;hpb=e7bc29984e91ee36555d6a4e4eece22170d10ba4;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index 83042a6..a59c939 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspgltk +Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Distributed under the LGPL +*/ + #include "root.h" namespace Msp { @@ -18,18 +25,27 @@ Root::Root(Resources &r, Window &w): void Root::button_press_event(int x, int y, unsigned btn, unsigned) { + 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); } void Root::pointer_motion_event(int x, int y) { + translate_coords(x, y); pointer_motion(x, y); } +void Root::translate_coords(int &x, int &y) +{ + x=x*geom.w/window.get_width(); + y=geom.h-1-y*geom.h/window.get_height(); +} + } // namespace GLtk } // namespace Msp