Fresco/GGI/GGIKit GGIKitImpl.cc,1.7,1.8 GGIKitImpl.hh,1.8,1.9 VisualImpl.cc,1.14,1.15 VisualImpl.hh,1.8,1.9
Tobias Hunger <[email protected]> Mon, 27 Oct 2003 17:08:43 +0000
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/GGI/GGIKit In directory purcel:/tmp/cvs-serv5328/GGI/GGIKit Modified Files: GGIKitImpl.cc GGIKitImpl.hh VisualImpl.cc VisualImpl.hh Log Message: Make sure all classes defined by Kits are in the Kit's namespace. Do some coding style fixups while touching the files anyway. Index: GGIKitImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/GGI/GGIKit/GGIKitImpl.cc,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- GGIKitImpl.cc 18 Feb 2003 07:26:41 -0000 1.7 +++ GGIKitImpl.cc 27 Oct 2003 17:08:40 -0000 1.8 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -24,13 +24,16 @@ using namespace Fresco; -GGIKitImpl::GGIKitImpl(const std::string &id, - const Fresco::Kit::PropertySeq &p, - ServerContextImpl *c) - : KitImpl(id, p, c) {} -GGIKitImpl::~GGIKitImpl() {} +GGI::Kit::GGIKitImpl::GGIKitImpl(const std::string &id, + const Fresco::Kit::PropertySeq &p, + ServerContextImpl *c) : + KitImpl(id, p, c) +{ } -GGI::Visual_ptr GGIKitImpl::create_visual(Fresco::PixelCoord w, Fresco::PixelCoord h) +GGI::Kit::GGIKitImpl::~GGIKitImpl() { } + +GGI::Visual_ptr GGI::Kit::GGIKitImpl::create_visual(Fresco::PixelCoord w, + Fresco::PixelCoord h) { return create<GGI::Visual>(new VisualImpl(w, h)); } @@ -39,6 +42,7 @@ extern "C" KitImpl *load() { - static std::string properties[] = {"implementation", "GGIKitImpl"}; - return create_prototype<GGIKitImpl>("IDL:GGI/GGIKit:1.0", properties, 2); -} + static std::string properties[] = {"implementation", "GGIKitImpl"}; + return create_prototype<GGI::Kit::GGIKitImpl>("IDL:GGI/GGIKit:1.0", + properties, 2); +} Index: GGIKitImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/GGI/GGIKit/GGIKitImpl.hh,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- GGIKitImpl.hh 18 Feb 2003 07:26:41 -0000 1.8 +++ GGIKitImpl.hh 27 Oct 2003 17:08:40 -0000 1.9 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -27,17 +27,28 @@ #include <Berlin/KitImpl.hh> #include <vector> -class GGIKitImpl : public virtual POA_GGI::GGIKit, - public KitImpl +namespace GGI { - public: - GGIKitImpl(const std::string &, - const Fresco::Kit::PropertySeq &, - ServerContextImpl *); - virtual ~GGIKitImpl(); - virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p, ServerContextImpl *c) - { return new GGIKitImpl(repo_id(), p, c);} - virtual GGI::Visual_ptr create_visual(Fresco::PixelCoord, Fresco::PixelCoord); -}; + namespace Kit + { + + class GGIKitImpl : public virtual POA_GGI::GGIKit, + public KitImpl + { + public: + GGIKitImpl(const std::string &, + const Fresco::Kit::PropertySeq &, + ServerContextImpl *); + virtual ~GGIKitImpl(); + virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p, + ServerContextImpl *c) + { + return new GGIKitImpl(repo_id(), p, c); + } + virtual GGI::Visual_ptr create_visual(Fresco::PixelCoord, Fresco::PixelCoord); + }; + + } // namespace +} // namespace #endif Index: VisualImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/GGI/GGIKit/VisualImpl.cc,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- VisualImpl.cc 29 Oct 2002 18:12:59 -0000 1.14 +++ VisualImpl.cc 27 Oct 2003 17:08:40 -0000 1.15 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -34,211 +34,211 @@ using namespace Prague; using namespace Fresco; -GGIDrawableFactory *VisualImpl::_factory = 0; +GGIDrawableFactory * GGI::GGIKit::VisualImpl::_factory = 0; -VisualImpl::VisualImpl(PixelCoord w, PixelCoord h) - : ControllerImpl(false), _width(w), _height(h) +GGI::GGIKit::VisualImpl::VisualImpl(PixelCoord w, PixelCoord h) : + ControllerImpl(false), + _width(w), + _height(h) { - Trace trace("VisualImpl::VisualImpl"); - Console *console = Console::instance(); - if (!_factory) _factory = console->get_extension<GGIDrawableFactory>("GGIDrawableFactory"); - Fresco::Drawable::PixelFormat format = Console::instance()->drawable()->pixel_format(); - /* - * the drawable plus some memory for the event queue - */ - size_t size = w * h * format.size + 64*1024; - _shm = SHM::allocate(size); + Trace trace("VisualImpl::VisualImpl"); + Console *console = Console::instance(); + if (!_factory) _factory = console->get_extension<GGIDrawableFactory>("GGIDrawableFactory"); + Fresco::Drawable::PixelFormat format = Console::instance()->drawable()->pixel_format(); + /* + * the drawable plus some memory for the event queue + */ + size_t size = w * h * format.size + 64*1024; + _shm = SHM::allocate(size); - _ggi = _factory->create_drawable(_shm, w, h, 3); - _drawable = console->activate_drawable(_ggi); - ggi_mode mode = _ggi->mode(); - char buffer[256]; - ggiSPrintMode(buffer, &mode); - _mode = buffer; + _ggi = _factory->create_drawable(_shm, w, h, 3); + _drawable = console->activate_drawable(_ggi); + ggi_mode mode = _ggi->mode(); + char buffer[256]; + ggiSPrintMode(buffer, &mode); + _mode = buffer; } -VisualImpl::~VisualImpl() +GGI::GGIKit::VisualImpl::~VisualImpl() { - Trace trace("VisualImpl::~VisualImpl"); - SHM::deallocate(_shm); + Trace trace("VisualImpl::~VisualImpl"); + SHM::deallocate(_shm); } -char *VisualImpl::name() +char * GGI::GGIKit::VisualImpl::name() { - return CORBA::string_dup(_ggi->name().c_str()); + return CORBA::string_dup(_ggi->name().c_str()); } -char *VisualImpl::mode() +char * GGI::GGIKit::VisualImpl::mode() { - return CORBA::string_dup(_mode.c_str()); + return CORBA::string_dup(_mode.c_str()); } -void VisualImpl::request(Fresco::Graphic::Requisition &requisition) +void GGI::GGIKit::VisualImpl::request(Fresco::Graphic::Requisition &requisition) { - Trace trace("VisualImpl::request"); - requisition.x.defined = true; - requisition.x.natural = requisition.x.maximum = requisition.x.minimum = _width / Console::instance()->drawable()->resolution(xaxis); - requisition.x.align = 0.; - requisition.y.defined = true; - requisition.y.natural = requisition.y.maximum = requisition.y.minimum = _height / Console::instance()->drawable()->resolution(yaxis); - requisition.y.align = 0.; - requisition.z.defined = false; + Trace trace("VisualImpl::request"); + requisition.x.defined = true; + requisition.x.natural = requisition.x.maximum = requisition.x.minimum = + _width / Console::instance()->drawable()->resolution(xaxis); + requisition.x.align = 0.; + requisition.y.defined = true; + requisition.y.natural = requisition.y.maximum = requisition.y.minimum = + _height / Console::instance()->drawable()->resolution(yaxis); + requisition.y.align = 0.; + requisition.z.defined = false; } -void VisualImpl::draw(DrawTraversal_ptr traversal) +void GGI::GGIKit::VisualImpl::draw(DrawTraversal_ptr traversal) { - Trace trace("VisualImpl::draw"); - DrawingKit_var drawing = traversal->drawing(); - drawing->copy_drawable(_drawable, 0, 0, _width, _height); + Trace trace("VisualImpl::draw"); + DrawingKit_var drawing = traversal->drawing(); + drawing->copy_drawable(_drawable, 0, 0, _width, _height); } -void VisualImpl::extension(const Allocation::Info &info, Region_ptr region) +void GGI::GGIKit::VisualImpl::extension(const Allocation::Info &info, Region_ptr region) { - Trace trace("VisualImpl::extension"); - GraphicImpl::extension(info, region); + Trace trace("VisualImpl::extension"); + GraphicImpl::extension(info, region); } -CORBA::Boolean VisualImpl::handle_positional(PickTraversal_ptr traversal, const Fresco::Input::Event &event) +CORBA::Boolean GGI::GGIKit::VisualImpl::handle_positional(PickTraversal_ptr traversal, + const Fresco::Input::Event &event) { - Trace trace("VisualImpl::handle_positional"); + Trace trace("VisualImpl::handle_positional"); - // Grab keyboard focus - // FIXME: hardcoded device values == Evil - if (!have_focus(0)) { - request_focus(Controller_var(_this()), 0); - } + // Grab keyboard focus + // FIXME: hardcoded device values == Evil + if (!have_focus(0)) request_focus(Controller_var(_this()), 0); - if (event[0].attr._d() == Input::button) - { - handle_pointer_button(event); - } - else if (event[0].attr._d() == Input::positional) - { - move(traversal, event); - } - else + if (event[0].attr._d() == Input::button) handle_pointer_button(event); + else if (event[0].attr._d() == Input::positional) move(traversal, event); + else { - std::cerr << "VisualImpl::handle_positional: " - << "Ignoring positional event" << std::endl; + std::cerr << "VisualImpl::handle_positional: " + << "Ignoring positional event" << std::endl; } - return true; + return true; } -CORBA::Boolean VisualImpl::handle_non_positional(const Fresco::Input::Event &event) +CORBA::Boolean GGI::GGIKit::VisualImpl::handle_non_positional(const Fresco::Input::Event &event) { - Trace trace("VisualImpl::handle_non_positional"); - /* - * FIXME !: we assume a lot about the (berlin) event layout here. Make that more flexible... - */ - Input::Toggle toggle = event[0].attr.selection(); - ggi_event ggi; - // giiEventSend will discard events without this field filled in. - // I'm not sure if the actual value should depend on the source of the - // event, or what (there's ggi.any.source for that, but that's filled in - // as being a fake event by EventSend; this seems to be about which of the - // input queues are handed the event. - ggi.any.target = GII_EV_TARGET_ALL; - // XGGI will crash (and understandably so!) if we don't fill this in - ggi.any.size = sizeof(gii_key_event); - if (toggle.actuation == Input::Toggle::press) ggi.any.type = evKeyPress; - else if (toggle.actuation == Input::Toggle::hold) ggi.any.type = evKeyRepeat; - else if (toggle.actuation == Input::Toggle::release) ggi.any.type = evKeyRelease; // not generated actually - ggi.key.modifiers = 0; // FIXME: wrong, should track state of modifier keys - ggi.key.sym = toggle.number; - // FIXME: the following is wildly incorrect: - ggi.key.label = toggle.number; // XGGI looks at this one - // ggi.key.label = 'L; // useful for testing, so it's obvious if an app - // is reading this field - ggi.key.button = 50; // == scancode for 'M', ditto - /* - * FIXME !: the ggi_event structure is quite incomplete here. The real structure looks so: + Trace trace("VisualImpl::handle_non_positional"); + /* + * FIXME !: we assume a lot about the (berlin) event layout here. Make that more flexible... + */ + Input::Toggle toggle = event[0].attr.selection(); + ggi_event ggi; + // giiEventSend will discard events without this field filled in. + // I'm not sure if the actual value should depend on the source of the + // event, or what (there's ggi.any.source for that, but that's filled in + // as being a fake event by EventSend; this seems to be about which of the + // input queues are handed the event. + ggi.any.target = GII_EV_TARGET_ALL; + // XGGI will crash (and understandably so!) if we don't fill this in + ggi.any.size = sizeof(gii_key_event); + if (toggle.actuation == Input::Toggle::press) ggi.any.type = evKeyPress; + else if (toggle.actuation == Input::Toggle::hold) ggi.any.type = evKeyRepeat; + else if (toggle.actuation == Input::Toggle::release) ggi.any.type = evKeyRelease; // not generated actually + ggi.key.modifiers = 0; // FIXME: wrong, should track state of modifier keys + ggi.key.sym = toggle.number; + // FIXME: the following is wildly incorrect: + ggi.key.label = toggle.number; // XGGI looks at this one + // ggi.key.label = 'L; // useful for testing, so it's obvious if an app + // is reading this field + ggi.key.button = 50; // == scancode for 'M', ditto + /* + * FIXME !: the ggi_event structure is quite incomplete here. The real structure looks so: - typedef struct { - - COMMON_DATA; - - uint32 modifiers; current modifiers in effect - uint32 sym; meaning of key (includes modifiers) - uint32 label; label on key - uint32 button; button number (== raw scancode) - - } gii_key_event; + typedef struct { - * and we need to figure out a way to fill the remaining members, i.e. reconstruct them from the sym - * given that this is the only information we conserve in the berlin key event... - */ - forward_event(ggi); - return true; + COMMON_DATA; + + uint32 modifiers; current modifiers in effect + uint32 sym; meaning of key (includes modifiers) + uint32 label; label on key + uint32 button; button number (== raw scancode) + + } gii_key_event; + + * and we need to figure out a way to fill the remaining members, i.e. reconstruct them from the sym + * given that this is the only information we conserve in the berlin key event... + */ + forward_event(ggi); + return true; } -void VisualImpl::move(Fresco::PickTraversal_ptr traversal, - const Input::Event &event) +void GGI::GGIKit::VisualImpl::move(Fresco::PickTraversal_ptr traversal, + const Input::Event &event) { - Trace trace("VisualImpl::move"); + Trace trace("VisualImpl::move"); - ggi_event ggi; - ggi.any.target = GII_EV_TARGET_ALL; - ggi.any.size = sizeof(gii_pmove_event); + ggi_event ggi; + ggi.any.target = GII_EV_TARGET_ALL; + ggi.any.size = sizeof(gii_pmove_event); - Input::Position position; - if (-1 == get_position(event, position)) { - std::cerr << "VisualImpl::move error: non-positional event!" - << std::endl; - return; - } - Transform_var trafo = traversal->current_transformation(); - trafo->inverse_transform_vertex(position); - ggi.any.type = evPtrAbsolute; - // This, really, is incorrect -- in (eg) the multihead case, we can't - // assume that there's One True Resolution. - // Perhaps people trying to run pixel-based apps across two displays at - // different resolutions deserve what they get... - const Fresco::Coord res_x = Console::instance()->drawable()->resolution(xaxis); - ggi.pmove.x = static_cast<int>(position.x * res_x); - const Fresco::Coord res_y = Console::instance()->drawable()->resolution(yaxis); - ggi.pmove.y = static_cast<int>(position.y * res_y); - const Fresco::Coord res_z = Console::instance()->drawable()->resolution(zaxis); - ggi.pmove.z = static_cast<int>(position.z * res_z); - ggi.pmove.wheel = 0; // I don't even know what this means. - forward_event(ggi); + Input::Position position; + if (-1 == get_position(event, position)) + { + std::cerr << "VisualImpl::move error: non-positional event!" + << std::endl; + return; + } + Transform_var trafo = traversal->current_transformation(); + trafo->inverse_transform_vertex(position); + ggi.any.type = evPtrAbsolute; + // This, really, is incorrect -- in (eg) the multihead case, we can't + // assume that there's One True Resolution. + // Perhaps people trying to run pixel-based apps across two displays at + // different resolutions deserve what they get... + const Fresco::Coord res_x = Console::instance()->drawable()->resolution(xaxis); + ggi.pmove.x = static_cast<int>(position.x * res_x); + const Fresco::Coord res_y = Console::instance()->drawable()->resolution(yaxis); + ggi.pmove.y = static_cast<int>(position.y * res_y); + const Fresco::Coord res_z = Console::instance()->drawable()->resolution(zaxis); + ggi.pmove.z = static_cast<int>(position.z * res_z); + ggi.pmove.wheel = 0; // I don't even know what this means. + forward_event(ggi); } -void VisualImpl::handle_pointer_button(const Input::Event &event) +void GGI::GGIKit::VisualImpl::handle_pointer_button(const Input::Event &event) { - Trace trace("VisualImpl::handle_pointer_button"); + Trace trace("VisualImpl::handle_pointer_button"); - Input::Toggle toggle; - // I stole this bit from Event.hh, get_position() - Input::Device device = event[0].dev; - for (size_t i = 0; i != event.length(); i++) { - // Why do we check the devices like this? - if (event[i].dev != device) continue; - if (event[i].attr._d() == Input::button) - { - toggle = event[i].attr.selection(); - break; - } - } - ggi_event ggi; - ggi.any.target = GII_EV_TARGET_ALL; - ggi.any.size = sizeof(ggi_pbutton_event); - if (toggle.actuation == Input::Toggle::press) - ggi.any.type = evPtrButtonPress; - else if (toggle.actuation == Input::Toggle::release) - ggi.any.type = evPtrButtonRelease; - else { - std::cerr << "VisualImpl::handle_pointer_button: " - << "unknown toggle -- neither press nor release!" - << std::endl; - return; - } - ggi.pbutton.button = toggle.number; - forward_event(ggi); + Input::Toggle toggle; + // I stole this bit from Event.hh, get_position() + Input::Device device = event[0].dev; + for (size_t i = 0; i != event.length(); i++) + { + // Why do we check the devices like this? + if (event[i].dev != device) continue; + if (event[i].attr._d() == Input::button) + { + toggle = event[i].attr.selection(); + break; + } + } + ggi_event ggi; + ggi.any.target = GII_EV_TARGET_ALL; + ggi.any.size = sizeof(ggi_pbutton_event); + if (toggle.actuation == Input::Toggle::press) + ggi.any.type = evPtrButtonPress; + else if (toggle.actuation == Input::Toggle::release) + ggi.any.type = evPtrButtonRelease; + else + { + std::cerr << "VisualImpl::handle_pointer_button: " + << "unknown toggle -- neither press nor release!" + << std::endl; + return; + } + ggi.pbutton.button = toggle.number; + forward_event(ggi); } -void VisualImpl::forward_event(const ggi_event &event) +void GGI::GGIKit::VisualImpl::forward_event(const ggi_event &event) { - Trace trace("VisualImpl::forward_event"); -// giiEventSend(ggiJoinInputs(_ggi->visual(), 0), const_cast<ggi_event *>(&event)); - ggiEventSend(_ggi->visual(), const_cast<ggi_event *>(&event)); + Trace trace("VisualImpl::forward_event"); + // giiEventSend(ggiJoinInputs(_ggi->visual(), 0), const_cast<ggi_event *>(&event)); + ggiEventSend(_ggi->visual(), const_cast<ggi_event *>(&event)); } Index: VisualImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/GGI/GGIKit/VisualImpl.hh,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- VisualImpl.hh 1 Jun 2002 10:02:22 -0000 1.8 +++ VisualImpl.hh 27 Oct 2003 17:08:40 -0000 1.9 @@ -1,7 +1,7 @@ /*$Id$ * * This source file is a part of the Fresco Project. - * Copyright (C) 2000 Stefan Seefeld <[email protected]> + * Copyright (C) 2000 Stefan Seefeld <[email protected]> * http://www.fresco.org * * This library is free software; you can redistribute it and/or @@ -32,31 +32,40 @@ #include <ggi/ggi-unix.h> } -class VisualImpl : public virtual POA_GGI::Visual, - public ControllerImpl +namespace GGI { -public: - VisualImpl(Fresco::PixelCoord, Fresco::PixelCoord); - virtual ~VisualImpl(); - virtual char *name(); - virtual char *mode(); - virtual void request(Fresco::Graphic::Requisition &); - virtual void draw(Fresco::DrawTraversal_ptr); - virtual void extension(const Fresco::Allocation::Info &info, Fresco::Region_ptr region); - virtual CORBA::Boolean handle_positional(Fresco::PickTraversal_ptr, const Fresco::Input::Event &); - virtual CORBA::Boolean handle_non_positional(const Fresco::Input::Event &); - // this overrides ControllerImpl: - virtual void move(Fresco::PickTraversal_ptr, const Fresco::Input::Event &); -private: - virtual void handle_pointer_button(const Fresco::Input::Event &); - void forward_event(const ggi_event &); - static GGIDrawableFactory *_factory; - Fresco::PixelCoord _width; - Fresco::PixelCoord _height; - Fresco::Drawable_var _drawable; - int _shm; - GGIDrawable *_ggi; - std::string _mode; -}; + namespace GGIKit + { + + class VisualImpl : public virtual POA_GGI::Visual, + public ControllerImpl + { + public: + VisualImpl(Fresco::PixelCoord, Fresco::PixelCoord); + virtual ~VisualImpl(); + virtual char *name(); + virtual char *mode(); + virtual void request(Fresco::Graphic::Requisition &); + virtual void draw(Fresco::DrawTraversal_ptr); + virtual void extension(const Fresco::Allocation::Info &info, Fresco::Region_ptr region); + virtual CORBA::Boolean handle_positional(Fresco::PickTraversal_ptr, + const Fresco::Input::Event &); + virtual CORBA::Boolean handle_non_positional(const Fresco::Input::Event &); + // this overrides ControllerImpl: + virtual void move(Fresco::PickTraversal_ptr, const Fresco::Input::Event &); + private: + virtual void handle_pointer_button(const Fresco::Input::Event &); + void forward_event(const ggi_event &); + static GGIDrawableFactory *_factory; + Fresco::PixelCoord _width; + Fresco::PixelCoord _height; + Fresco::Drawable_var _drawable; + int _shm; + GGIDrawable *_ggi; + std::string _mode; + }; + + } // namepace +} // namespace #endif