From 45b1b6ff3b030c0372f1efff2baad989b02725a9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 3 Aug 2011 16:04:45 -0400 Subject: CHOP-763: Remove redundant KEY string names from llwindowlistener.cpp. A couple of the lookup tables in llwindowlistener.cpp essentially duplicated LLKeyboard::keyFromString() and maskFromString(). Remove those tables and use LLKeyboard lookup methods instead. --- indra/llwindow/llwindowlistener.cpp | 135 +++++++++--------------------------- 1 file changed, 31 insertions(+), 104 deletions(-) (limited to 'indra') diff --git a/indra/llwindow/llwindowlistener.cpp b/indra/llwindow/llwindowlistener.cpp index 91b99d83c6..006aaa75e7 100644 --- a/indra/llwindow/llwindowlistener.cpp +++ b/indra/llwindow/llwindowlistener.cpp @@ -41,10 +41,10 @@ LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGett std::string keySomething = "Given [\"keysym\"], [\"keycode\"] or [\"char\"], inject the specified "; std::string keyExplain = - "(integer keycode values, or keysym \"XXXX\" from any KEY_XXXX, in\n" - "http://hg.secondlife.com/viewer-development/src/tip/indra/llcommon/indra_constants.h )"; + "(integer keycode values, or keysym string from any addKeyName() call in\n" + "http://hg.secondlife.com/viewer-development/src/tip/indra/llwindow/llkeyboard.cpp )"; std::string mask = - "Specify optional [\"mask\"] as an array containing any of \"CONTROL\", \"ALT\",\n" + "Specify optional [\"mask\"] as an array containing any of \"CTL\", \"ALT\",\n" "\"SHIFT\" or \"MAC_CONTROL\"; the corresponding modifier bits will be combined\n" "to form the mask used with the event."; @@ -104,118 +104,41 @@ protected: } }; -// for WhichKeysym. KeyProxy is like the typedef KEY, except that KeyProxy() -// (default-constructed) is guaranteed to have the value KEY_NONE. -class KeyProxy +// helper for getMask() +static MASK lookupMask_(const std::string& maskname) { -public: - KeyProxy(KEY k): mKey(k) {} - KeyProxy(): mKey(KEY_NONE) {} - operator KEY() const { return mKey; } - -private: - KEY mKey; -}; - -struct WhichKeysym: public StringLookup -{ - WhichKeysym(): StringLookup("keysym") + // It's unclear to me whether MASK_MAC_CONTROL is important, but it's not + // supported by maskFromString(). Handle that specially. + if (maskname == "MAC_CONTROL") { - add("RETURN", KEY_RETURN); - add("LEFT", KEY_LEFT); - add("RIGHT", KEY_RIGHT); - add("UP", KEY_UP); - add("DOWN", KEY_DOWN); - add("ESCAPE", KEY_ESCAPE); - add("BACKSPACE", KEY_BACKSPACE); - add("DELETE", KEY_DELETE); - add("SHIFT", KEY_SHIFT); - add("CONTROL", KEY_CONTROL); - add("ALT", KEY_ALT); - add("HOME", KEY_HOME); - add("END", KEY_END); - add("PAGE_UP", KEY_PAGE_UP); - add("PAGE_DOWN", KEY_PAGE_DOWN); - add("HYPHEN", KEY_HYPHEN); - add("EQUALS", KEY_EQUALS); - add("INSERT", KEY_INSERT); - add("CAPSLOCK", KEY_CAPSLOCK); - add("TAB", KEY_TAB); - add("ADD", KEY_ADD); - add("SUBTRACT", KEY_SUBTRACT); - add("MULTIPLY", KEY_MULTIPLY); - add("DIVIDE", KEY_DIVIDE); - add("F1", KEY_F1); - add("F2", KEY_F2); - add("F3", KEY_F3); - add("F4", KEY_F4); - add("F5", KEY_F5); - add("F6", KEY_F6); - add("F7", KEY_F7); - add("F8", KEY_F8); - add("F9", KEY_F9); - add("F10", KEY_F10); - add("F11", KEY_F11); - add("F12", KEY_F12); - - add("PAD_UP", KEY_PAD_UP); - add("PAD_DOWN", KEY_PAD_DOWN); - add("PAD_LEFT", KEY_PAD_LEFT); - add("PAD_RIGHT", KEY_PAD_RIGHT); - add("PAD_HOME", KEY_PAD_HOME); - add("PAD_END", KEY_PAD_END); - add("PAD_PGUP", KEY_PAD_PGUP); - add("PAD_PGDN", KEY_PAD_PGDN); - add("PAD_CENTER", KEY_PAD_CENTER); // the 5 in the middle - add("PAD_INS", KEY_PAD_INS); - add("PAD_DEL", KEY_PAD_DEL); - add("PAD_RETURN", KEY_PAD_RETURN); - add("PAD_ADD", KEY_PAD_ADD); // not used - add("PAD_SUBTRACT", KEY_PAD_SUBTRACT); // not used - add("PAD_MULTIPLY", KEY_PAD_MULTIPLY); // not used - add("PAD_DIVIDE", KEY_PAD_DIVIDE); // not used - - add("BUTTON0", KEY_BUTTON0); - add("BUTTON1", KEY_BUTTON1); - add("BUTTON2", KEY_BUTTON2); - add("BUTTON3", KEY_BUTTON3); - add("BUTTON4", KEY_BUTTON4); - add("BUTTON5", KEY_BUTTON5); - add("BUTTON6", KEY_BUTTON6); - add("BUTTON7", KEY_BUTTON7); - add("BUTTON8", KEY_BUTTON8); - add("BUTTON9", KEY_BUTTON9); - add("BUTTON10", KEY_BUTTON10); - add("BUTTON11", KEY_BUTTON11); - add("BUTTON12", KEY_BUTTON12); - add("BUTTON13", KEY_BUTTON13); - add("BUTTON14", KEY_BUTTON14); - add("BUTTON15", KEY_BUTTON15); + return MASK_MAC_CONTROL; } -}; -static WhichKeysym keysyms; - -struct WhichMask: public StringLookup -{ - WhichMask(): StringLookup("shift mask") + else { - add("NONE", MASK_NONE); - add("CONTROL", MASK_CONTROL); // Mapped to cmd on Macs - add("ALT", MASK_ALT); - add("SHIFT", MASK_SHIFT); - add("MAC_CONTROL", MASK_MAC_CONTROL); // Un-mapped Ctrl key on Macs, not used on Windows + // In case of lookup failure, return MASK_NONE, which won't affect our + // caller's OR. + MASK mask(MASK_NONE); + LLKeyboard::maskFromString(maskname, &mask); + return mask; } -}; -static WhichMask masks; +} static MASK getMask(const LLSD& event) { - MASK mask(MASK_NONE); LLSD masknames(event["mask"]); + if (! masknames.isArray()) + { + // If event["mask"] is a single string, perform normal lookup on it. + return lookupMask_(masknames); + } + + // Here event["mask"] is an array of mask-name strings. OR together their + // corresponding bits. + MASK mask(MASK_NONE); for (LLSD::array_const_iterator ai(masknames.beginArray()), aend(masknames.endArray()); ai != aend; ++ai) { - mask |= masks.lookup(*ai); + mask |= lookupMask_(*ai); } return mask; } @@ -224,7 +147,11 @@ static KEY getKEY(const LLSD& event) { if (event.has("keysym")) { - return keysyms.lookup(event["keysym"]); + // Initialize to KEY_NONE; that way we can ignore the bool return from + // keyFromString() and, in the lookup-fail case, simply return KEY_NONE. + KEY key(KEY_NONE); + LLKeyboard::keyFromString(event["keysym"], &key); + return key; } else if (event.has("keycode")) { -- cgit v1.2.3 From a44fb94af2974fce07575f30f5dcaff9729d9ba9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 11 Aug 2011 17:41:54 -0400 Subject: CHOP-763: Reduce redundancy in LLView::childrenHandle*() methods. There were 13 different methods that were more or less clones of each other. Consolidate those down to 5 variations on the basic method body, where each variation has good (commented!) reason to differ. Use helper methods to further simplify the remaining distinct method bodies. Use BOOST_FOREACH() to improve readability of iterating over mChildList. --- indra/llui/llview.cpp | 496 ++++++++++++-------------------------------------- indra/llui/llview.h | 17 ++ 2 files changed, 129 insertions(+), 384 deletions(-) (limited to 'indra') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 8803d106ba..f41e43c0cf 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "llrender.h" #include "llevent.h" @@ -346,13 +347,11 @@ void LLView::removeChild(LLView* child) LLView::ctrl_list_t LLView::getCtrlList() const { ctrl_list_t controls; - for(child_list_const_iter_t iter = mChildList.begin(); - iter != mChildList.end(); - iter++) + BOOST_FOREACH(LLView* viewp, mChildList) { - if((*iter)->isCtrl()) + if(viewp->isCtrl()) { - controls.push_back(static_cast(*iter)); + controls.push_back(static_cast(viewp)); } } return controls; @@ -574,9 +573,8 @@ void LLView::deleteAllChildren() void LLView::setAllChildrenEnabled(BOOL b) { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; viewp->setEnabled(b); } } @@ -602,9 +600,8 @@ void LLView::setVisible(BOOL visible) // virtual void LLView::handleVisibilityChange ( BOOL new_visibility ) { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; // only views that are themselves visible will have their overall visibility affected by their ancestors if (viewp->getVisible()) { @@ -646,39 +643,71 @@ void LLView::onMouseLeave(S32 x, S32 y, MASK mask) //llinfos << "Mouse left " << getName() << llendl; } +bool LLView::visibleAndContains(S32 local_x, S32 local_y) +{ + return pointInView(local_x, local_y) + && getVisible(); +} -LLView* LLView::childrenHandleToolTip(S32 x, S32 y, MASK mask) +bool LLView::visibleEnabledAndContains(S32 local_x, S32 local_y) +{ + return visibleAndContains(local_x, local_y) + && getEnabled(); +} + +void LLView::logMouseEvent() +{ + if (sDebugMouseHandling) + { + sMouseHandlerMessage = std::string("/") + mName + sMouseHandlerMessage; + } +} + +// XDATA might be MASK, or S32 clicks +template +LLView* LLView::childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra) { - LLView* handled_view = NULL; - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; S32 local_x = x - viewp->getRect().mLeft; S32 local_y = y - viewp->getRect().mBottom; - if(!viewp->pointInView(local_x, local_y) - || !viewp->getVisible()) + + if (!viewp->visibleEnabledAndContains(local_x, local_y)) { continue; } - if (viewp->handleToolTip(local_x, local_y, mask) ) + if ((viewp->*method)( local_x, local_y, extra ) + || viewp->blockMouseEvent( local_x, local_y )) { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } + viewp->logMouseEvent(); + return viewp; + } + } + return NULL; +} - handled_view = viewp; - break; +LLView* LLView::childrenHandleToolTip(S32 x, S32 y, MASK mask) +{ + BOOST_FOREACH(LLView* viewp, mChildList) + { + S32 local_x = x - viewp->getRect().mLeft; + S32 local_y = y - viewp->getRect().mBottom; + // Differs from childrenHandleMouseEvent() in that we want to offer + // tooltips even for disabled widgets. + if(!viewp->visibleAndContains(local_x, local_y)) + { + continue; } - if (viewp->blockMouseEvent(local_x, local_y)) + if (viewp->handleToolTip(local_x, local_y, mask) + || viewp->blockMouseEvent(local_x, local_y)) { - handled_view = viewp; - break; + viewp->logMouseEvent(); + return viewp; } } - return handled_view; + return NULL; } @@ -686,13 +715,11 @@ LLView* LLView::childFromPoint(S32 x, S32 y) { if (!getVisible() ) return false; - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; S32 local_x = x - viewp->getRect().mLeft; S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() ) + if (!viewp->visibleAndContains(local_x, local_y)) { continue; } @@ -822,36 +849,31 @@ LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, EAcceptance* accept, std::string& tooltip_msg) { - LLView* handled_view = NULL; - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + // default to not accepting drag and drop, will be overridden by handler + *accept = ACCEPT_NO; + + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; S32 local_x = x - viewp->getRect().mLeft; S32 local_y = y - viewp->getRect().mBottom; - if( !viewp->pointInView(local_x, local_y) || - !viewp->getVisible() || - !viewp->getEnabled()) + if( !viewp->visibleEnabledAndContains(local_x, local_y)) { continue; } + + // Differs from childrenHandleMouseEvent() simply in that this virtual + // method call diverges pretty radically from the usual (x, y, int). if (viewp->handleDragAndDrop(local_x, local_y, mask, drop, cargo_type, cargo_data, accept, - tooltip_msg)) + tooltip_msg) + || viewp->blockMouseEvent(local_x, local_y)) { - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(x, y)) - { - *accept = ACCEPT_NO; - handled_view = viewp; - break; + return viewp; } } - return handled_view; + return NULL; } void LLView::onMouseCaptureLost() @@ -906,388 +928,100 @@ BOOL LLView::handleMiddleMouseUp(S32 x, S32 y, MASK mask) LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) { - LLView* handled_view = NULL; - if (getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if (viewp->handleScrollWheel( local_x, local_y, clicks )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleScrollWheel, x, y, clicks); } LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - if (getVisible() && getEnabled() ) + BOOST_FOREACH(LLView* viewp, mChildList) { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + S32 local_x = x - viewp->getRect().mLeft; + S32 local_y = y - viewp->getRect().mBottom; + if(!viewp->visibleEnabledAndContains(local_x, local_y)) { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if(!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if (viewp->handleHover(local_x, local_y, mask) ) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - - handled_view = viewp; - break; - } + continue; + } - if (viewp->blockMouseEvent(local_x, local_y)) - { - LLUI::sWindow->setCursor(viewp->getHoverCursor()); + // This call differentiates this method from childrenHandleMouseEvent(). + LLUI::sWindow->setCursor(viewp->getHoverCursor()); - handled_view = viewp; - break; - } + if (viewp->handleHover(local_x, local_y, mask) + || viewp->blockMouseEvent(local_x, local_y)) + { + viewp->logMouseEvent(); + return viewp; } } - return handled_view; + return NULL; } -// Called during downward traversal -LLView* LLView::childrenHandleKey(KEY key, MASK mask) +template +LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, + CHARTYPE c, MASK mask) { - LLView* handled_view = NULL; - if ( getVisible() && getEnabled() ) { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; - if (viewp->handleKey(key, mask, TRUE)) + if ((viewp->*method)(c, mask, TRUE)) { if (LLView::sDebugKeys) { - llinfos << "Key handled by " << viewp->getName() << llendl; + llinfos << desc << " handled by " << viewp->getName() << llendl; } - handled_view = viewp; - break; + return viewp; } } } + return NULL; +} - return handled_view; +// Called during downward traversal +LLView* LLView::childrenHandleKey(KEY key, MASK mask) +{ + return childrenHandleCharEvent("Key", &LLView::handleKey, key, mask); } // Called during downward traversal LLView* LLView::childrenHandleUnicodeChar(llwchar uni_char) { - LLView* handled_view = NULL; - - if ( getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - if (viewp->handleUnicodeChar(uni_char, TRUE)) - { - if (LLView::sDebugKeys) - { - llinfos << "Unicode character handled by " << viewp->getName() << llendl; - } - handled_view = viewp; - break; - } - } - } - - return handled_view; + return childrenHandleCharEvent("Unicode character", &LLView::handleUnicodeCharWithDummyMask, + uni_char, MASK_NONE); } LLView* LLView::childrenHandleMouseDown(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if(viewp->handleMouseDown( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if(viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleMouseDown, x, y, mask); } LLView* LLView::childrenHandleRightMouseDown(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - - if (getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if (viewp->handleRightMouseDown( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleRightMouseDown, x, y, mask); } LLView* LLView::childrenHandleMiddleMouseDown(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - - if (getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if(viewp->handleMiddleMouseDown( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleMiddleMouseDown, x, y, mask); } LLView* LLView::childrenHandleDoubleClick(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - - if (getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if (viewp->handleDoubleClick( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleDoubleClick, x, y, mask); } LLView* LLView::childrenHandleMouseUp(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - if( getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if (viewp->handleMouseUp( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleMouseUp, x, y, mask); } LLView* LLView::childrenHandleRightMouseUp(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - if( getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled() ) - { - continue; - } - - if(viewp->handleRightMouseUp( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if(viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleRightMouseUp, x, y, mask); } LLView* LLView::childrenHandleMiddleMouseUp(S32 x, S32 y, MASK mask) { - LLView* handled_view = NULL; - if( getVisible() && getEnabled() ) - { - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) - { - LLView* viewp = *child_it; - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if (!viewp->pointInView(local_x, local_y) - || !viewp->getVisible() - || !viewp->getEnabled()) - { - continue; - } - - if(viewp->handleMiddleMouseUp( local_x, local_y, mask )) - { - if (sDebugMouseHandling) - { - sMouseHandlerMessage = std::string("/") + viewp->mName + sMouseHandlerMessage; - } - handled_view = viewp; - break; - } - - if (viewp->blockMouseEvent(local_x, local_y)) - { - handled_view = viewp; - break; - } - } - } - return handled_view; + return childrenHandleMouseEvent(&LLView::handleMiddleMouseUp, x, y, mask); } void LLView::draw() @@ -1460,9 +1194,8 @@ void LLView::reshape(S32 width, S32 height, BOOL called_from_parent) mRect.mTop = getRect().mBottom + height; // move child views according to reshape flags - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* viewp, mChildList) { - LLView* viewp = *child_it; LLRect child_rect( viewp->mRect ); if (viewp->followsRight() && viewp->followsLeft()) @@ -1525,10 +1258,8 @@ LLRect LLView::calcBoundingRect() { LLRect local_bounding_rect = LLRect::null; - child_list_const_iter_t child_it; - for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* childp, mChildList) { - LLView* childp = *child_it; // ignore invisible and "top" children when calculating bounding rect // such as combobox popups if (!childp->getVisible() || childp == gFocusMgr.getTopCtrl()) @@ -1689,11 +1420,9 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const //richard: should we allow empty names? //if(name.empty()) // return NULL; - child_list_const_iter_t child_it; // Look for direct children *first* - for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* childp, mChildList) { - LLView* childp = *child_it; llassert(childp); if (childp->getName() == name) { @@ -1703,9 +1432,8 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const if (recurse) { // Look inside each child as well. - for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* childp, mChildList) { - LLView* childp = *child_it; llassert(childp); LLView* viewp = childp->findChildView(name, recurse); if ( viewp ) @@ -2811,9 +2539,9 @@ S32 LLView::notifyParent(const LLSD& info) bool LLView::notifyChildren(const LLSD& info) { bool ret = false; - for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it) + BOOST_FOREACH(LLView* childp, mChildList) { - ret |= (*child_it)->notifyChildren(info); + ret = ret || childp->notifyChildren(info); } return ret; } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 594a5eec6b..daea46d330 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -516,6 +516,9 @@ protected: void drawDebugRect(); void drawChild(LLView* childp, S32 x_offset = 0, S32 y_offset = 0, BOOL force_draw = FALSE); void drawChildren(); + bool visibleAndContains(S32 local_x, S32 local_Y); + bool visibleEnabledAndContains(S32 local_x, S32 local_y); + void logMouseEvent(); LLView* childrenHandleKey(KEY key, MASK mask); LLView* childrenHandleUnicodeChar(llwchar uni_char); @@ -541,6 +544,20 @@ protected: private: + template + LLView* childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra); + + template + LLView* childrenHandleCharEvent(const std::string& desc, const METHOD& method, + CHARTYPE c, MASK mask); + + // adapter to blur distinction between handleKey() and handleUnicodeChar() + // for childrenHandleCharEvent() + BOOL handleUnicodeCharWithDummyMask(llwchar uni_char, MASK /* dummy */, BOOL from_parent) + { + return handleUnicodeChar(uni_char, from_parent); + } + LLView* mParentView; child_list_t mChildList; -- cgit v1.2.3 From a548fd52e3c938614f213ae7f2b1aa9cbf05b23f Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 11 Aug 2011 17:54:27 -0400 Subject: CHOP-763: Collect nontrivial LLView::childrenHandle*() methods. There are 5 remaining childrenHandleSomething() methods with nontrivial bodies -- the rest all forward to one of those 5. Move them all to be physically adjacent in the source file to make it easy to compare/maintain. --- indra/llui/llview.cpp | 158 +++++++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 80 deletions(-) (limited to 'indra') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index f41e43c0cf..6d0bd4d520 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -663,6 +663,27 @@ void LLView::logMouseEvent() } } +template +LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, + CHARTYPE c, MASK mask) +{ + if ( getVisible() && getEnabled() ) + { + BOOST_FOREACH(LLView* viewp, mChildList) + { + if ((viewp->*method)(c, mask, TRUE)) + { + if (LLView::sDebugKeys) + { + llinfos << desc << " handled by " << viewp->getName() << llendl; + } + return viewp; + } + } + } + return NULL; +} + // XDATA might be MASK, or S32 clicks template LLView* LLView::childrenHandleMouseEvent(const METHOD& method, S32 x, S32 y, XDATA extra) @@ -710,6 +731,63 @@ LLView* LLView::childrenHandleToolTip(S32 x, S32 y, MASK mask) return NULL; } +LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, + BOOL drop, + EDragAndDropType cargo_type, + void* cargo_data, + EAcceptance* accept, + std::string& tooltip_msg) +{ + // default to not accepting drag and drop, will be overridden by handler + *accept = ACCEPT_NO; + + BOOST_FOREACH(LLView* viewp, mChildList) + { + S32 local_x = x - viewp->getRect().mLeft; + S32 local_y = y - viewp->getRect().mBottom; + if( !viewp->visibleEnabledAndContains(local_x, local_y)) + { + continue; + } + + // Differs from childrenHandleMouseEvent() simply in that this virtual + // method call diverges pretty radically from the usual (x, y, int). + if (viewp->handleDragAndDrop(local_x, local_y, mask, drop, + cargo_type, + cargo_data, + accept, + tooltip_msg) + || viewp->blockMouseEvent(local_x, local_y)) + { + return viewp; + } + } + return NULL; +} + +LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) +{ + BOOST_FOREACH(LLView* viewp, mChildList) + { + S32 local_x = x - viewp->getRect().mLeft; + S32 local_y = y - viewp->getRect().mBottom; + if(!viewp->visibleEnabledAndContains(local_x, local_y)) + { + continue; + } + + // This call differentiates this method from childrenHandleMouseEvent(). + LLUI::sWindow->setCursor(viewp->getHoverCursor()); + + if (viewp->handleHover(local_x, local_y, mask) + || viewp->blockMouseEvent(local_x, local_y)) + { + viewp->logMouseEvent(); + return viewp; + } + } + return NULL; +} LLView* LLView::childFromPoint(S32 x, S32 y) { @@ -842,40 +920,6 @@ BOOL LLView::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, return childrenHandleDragAndDrop( x, y, mask, drop, cargo_type, cargo_data, accept, tooltip_msg) != NULL; } -LLView* LLView::childrenHandleDragAndDrop(S32 x, S32 y, MASK mask, - BOOL drop, - EDragAndDropType cargo_type, - void* cargo_data, - EAcceptance* accept, - std::string& tooltip_msg) -{ - // default to not accepting drag and drop, will be overridden by handler - *accept = ACCEPT_NO; - - BOOST_FOREACH(LLView* viewp, mChildList) - { - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if( !viewp->visibleEnabledAndContains(local_x, local_y)) - { - continue; - } - - // Differs from childrenHandleMouseEvent() simply in that this virtual - // method call diverges pretty radically from the usual (x, y, int). - if (viewp->handleDragAndDrop(local_x, local_y, mask, drop, - cargo_type, - cargo_data, - accept, - tooltip_msg) - || viewp->blockMouseEvent(local_x, local_y)) - { - return viewp; - } - } - return NULL; -} - void LLView::onMouseCaptureLost() { } @@ -925,57 +969,11 @@ BOOL LLView::handleMiddleMouseUp(S32 x, S32 y, MASK mask) return childrenHandleMiddleMouseUp( x, y, mask ) != NULL; } - LLView* LLView::childrenHandleScrollWheel(S32 x, S32 y, S32 clicks) { return childrenHandleMouseEvent(&LLView::handleScrollWheel, x, y, clicks); } -LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) -{ - BOOST_FOREACH(LLView* viewp, mChildList) - { - S32 local_x = x - viewp->getRect().mLeft; - S32 local_y = y - viewp->getRect().mBottom; - if(!viewp->visibleEnabledAndContains(local_x, local_y)) - { - continue; - } - - // This call differentiates this method from childrenHandleMouseEvent(). - LLUI::sWindow->setCursor(viewp->getHoverCursor()); - - if (viewp->handleHover(local_x, local_y, mask) - || viewp->blockMouseEvent(local_x, local_y)) - { - viewp->logMouseEvent(); - return viewp; - } - } - return NULL; -} - -template -LLView* LLView::childrenHandleCharEvent(const std::string& desc, const METHOD& method, - CHARTYPE c, MASK mask) -{ - if ( getVisible() && getEnabled() ) - { - BOOST_FOREACH(LLView* viewp, mChildList) - { - if ((viewp->*method)(c, mask, TRUE)) - { - if (LLView::sDebugKeys) - { - llinfos << desc << " handled by " << viewp->getName() << llendl; - } - return viewp; - } - } - } - return NULL; -} - // Called during downward traversal LLView* LLView::childrenHandleKey(KEY key, MASK mask) { -- cgit v1.2.3 From f7a6ed85e40f53e5e28868bf34ac4dbc9bb204fb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 25 Aug 2011 14:40:53 -0400 Subject: CHOP-763: Add LLView::TemporaryDrilldownFunc to support UI injection. Instead of unconditionally calling LLView::pointInView(), LLView::visibleAndContains() now consults a class-static boost::function called sDrilldown -- which is initialized to LLView::pointInView(). Introduce LLView::TemporaryDrilldownFunc, instantiated with a callable whose signature is compatible with LLView::pointInView(). This replaces sDrilldown, but only for the life of the TemporaryDrilldownFunc object. Introduce llview::TargetEvent, an object intended to serve as a TemporaryDrilldownFunc callable. Construct it with a desired target LLView* and pass it to TemporaryDrilldownFunc. When called with each candidate child LLView*, instead of selecting the one containing the particular (x, y) point, it selects the one that will lead to the ultimate desired target LLView*. Add optional 'recur' param to LLView::childFromPoint(); default is current one-level behavior. But when you pass recur=true, it should return the frontmost visible leaf LLView containing the passed (x, y) point. --- indra/llui/CMakeLists.txt | 2 ++ indra/llui/llview.cpp | 18 ++++++++++++--- indra/llui/llview.h | 31 ++++++++++++++++++++++++- indra/llui/llviewinject.cpp | 49 +++++++++++++++++++++++++++++++++++++++ indra/llui/llviewinject.h | 56 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 152 insertions(+), 4 deletions(-) create mode 100644 indra/llui/llviewinject.cpp create mode 100644 indra/llui/llviewinject.h (limited to 'indra') diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt index 0bbdcfd6ff..9419f24809 100644 --- a/indra/llui/CMakeLists.txt +++ b/indra/llui/CMakeLists.txt @@ -111,6 +111,7 @@ set(llui_SOURCE_FILES llurlmatch.cpp llurlregistry.cpp llviewborder.cpp + llviewinject.cpp llviewmodel.cpp llview.cpp llviewquery.cpp @@ -214,6 +215,7 @@ set(llui_HEADER_FILES llurlmatch.h llurlregistry.h llviewborder.h + llviewinject.h llviewmodel.h llview.h llviewquery.h diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 6d0bd4d520..56b09791a4 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "llrender.h" #include "llevent.h" @@ -67,6 +68,8 @@ S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; std::vector LLViewDrawContext::sDrawContextStack; +LLView::DrilldownFunc LLView::sDrilldown = + boost::bind(&LLView::pointInView, _1, _2, _3, HIT_TEST_USE_BOUNDING_RECT); //#if LL_DEBUG BOOL LLView::sIsDrawing = FALSE; @@ -645,7 +648,7 @@ void LLView::onMouseLeave(S32 x, S32 y, MASK mask) bool LLView::visibleAndContains(S32 local_x, S32 local_y) { - return pointInView(local_x, local_y) + return sDrilldown(this, local_x, local_y) && getVisible(); } @@ -789,10 +792,11 @@ LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask) return NULL; } -LLView* LLView::childFromPoint(S32 x, S32 y) +LLView* LLView::childFromPoint(S32 x, S32 y, bool recur) { - if (!getVisible() ) + if (!getVisible()) return false; + BOOST_FOREACH(LLView* viewp, mChildList) { S32 local_x = x - viewp->getRect().mLeft; @@ -801,6 +805,14 @@ LLView* LLView::childFromPoint(S32 x, S32 y) { continue; } + // Here we've found the first (frontmost) visible child at this level + // containing the specified point. Is the caller asking us to drill + // down and return the innermost leaf child at this point, or just the + // top-level child? + if (recur) + { + return viewp->childFromPoint(local_x, local_y, recur); + } return viewp; } diff --git a/indra/llui/llview.h b/indra/llui/llview.h index daea46d330..67634938fb 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -50,6 +50,7 @@ #include "llfocusmgr.h" #include +#include class LLSD; @@ -437,7 +438,7 @@ public: /*virtual*/ void screenPointToLocal(S32 screen_x, S32 screen_y, S32* local_x, S32* local_y) const; /*virtual*/ void localPointToScreen(S32 local_x, S32 local_y, S32* screen_x, S32* screen_y) const; - virtual LLView* childFromPoint(S32 x, S32 y); + virtual LLView* childFromPoint(S32 x, S32 y, bool recur=false); // view-specific handlers virtual void onMouseEnter(S32 x, S32 y, MASK mask); @@ -599,7 +600,35 @@ private: LLView& getDefaultWidgetContainer() const; + // This allows special mouse-event targeting logic for testing. + typedef boost::function DrilldownFunc; + static DrilldownFunc sDrilldown; + public: + // This is the only public accessor to alter sDrilldown. This is not + // an accident. The intended usage pattern is like: + // { + // LLView::TemporaryDrilldownFunc scoped_func(myfunctor); + // // ... test with myfunctor ... + // } // exiting block restores original LLView::sDrilldown + class TemporaryDrilldownFunc + { + public: + TemporaryDrilldownFunc(const DrilldownFunc& func): + mOldDrilldown(sDrilldown) + { + sDrilldown = func; + } + + ~TemporaryDrilldownFunc() + { + sDrilldown = mOldDrilldown; + } + + private: + DrilldownFunc mOldDrilldown; + }; + // Depth in view hierarchy during rendering static S32 sDepth; diff --git a/indra/llui/llviewinject.cpp b/indra/llui/llviewinject.cpp new file mode 100644 index 0000000000..46c5839f8e --- /dev/null +++ b/indra/llui/llviewinject.cpp @@ -0,0 +1,49 @@ +/** + * @file llviewinject.cpp + * @author Nat Goodspeed + * @date 2011-08-16 + * @brief Implementation for llviewinject. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "linden_common.h" +// associated header +#include "llviewinject.h" +// STL headers +// std headers +// external library headers +// other Linden headers + +llview::TargetEvent::TargetEvent(LLView* view) +{ + // Walk up the view tree from target LLView to the root (NULL). If + // passed NULL, iterate 0 times. + for (; view; view = view->getParent()) + { + // At each level, operator() is going to ask: for a particular parent + // LLView*, which of its children should I select? So for this view's + // parent, select this view. + mChildMap[view->getParent()] = view; + } +} + +bool llview::TargetEvent::operator()(const LLView* view, S32 /*x*/, S32 /*y*/) const +{ + // We are being called to decide whether to direct an incoming mouse event + // to this child view. (Normal LLView processing is to check whether the + // incoming (x, y) is within the view.) Look up the parent to decide + // whether, for that parent, this is the previously-selected child. + ChildMap::const_iterator found(mChildMap.find(view->getParent())); + // If we're looking at a child whose parent isn't even in the map, never + // mind. + if (found == mChildMap.end()) + { + return false; + } + // So, is this the predestined child for this parent? + return (view == found->second); +} diff --git a/indra/llui/llviewinject.h b/indra/llui/llviewinject.h new file mode 100644 index 0000000000..0de3d155c4 --- /dev/null +++ b/indra/llui/llviewinject.h @@ -0,0 +1,56 @@ +/** + * @file llviewinject.h + * @author Nat Goodspeed + * @date 2011-08-16 + * @brief Supplemental LLView functionality used for simulating UI events. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_LLVIEWINJECT_H) +#define LL_LLVIEWINJECT_H + +#include "llview.h" +#include + +namespace llview +{ + + /** + * TargetEvent is a callable with state, specifically intended for use as + * an LLView::TemporaryDrilldownFunc. Instantiate it with the desired + * target LLView*; pass it to a TemporaryDrilldownFunc instance; + * TargetEvent::operator() will then attempt to direct subsequent mouse + * events to the desired target LLView*. (This is an "attempt" because + * LLView will still balk unless the target LLView and every parent are + * visible and enabled.) + */ + class TargetEvent + { + public: + /** + * Construct TargetEvent with the desired target LLView*. (See + * LLUI::resolvePath() to obtain an LLView* given a string pathname.) + * This sets up for operator(). + */ + TargetEvent(LLView* view); + + /** + * This signature must match LLView::DrilldownFunc. When you install + * this TargetEvent instance using LLView::TemporaryDrilldownFunc, + * LLView will call this method to decide whether to propagate an + * incoming mouse event to the passed child LLView*. + */ + bool operator()(const LLView*, S32 x, S32 y) const; + + private: + // For a given parent LLView, identify which child to select. + typedef std::map ChildMap; + ChildMap mChildMap; + }; + +} // llview namespace + +#endif /* ! defined(LL_LLVIEWINJECT_H) */ -- cgit v1.2.3 From 79f14b7febf512e96a7d63eff8e6db895a7e72cf Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 25 Aug 2011 14:54:38 -0400 Subject: CHOP-763: Move llwindowlistener.{h,cpp} from llwindow to newview. Instantiate LLWindowListener on LLViewerWindow instead of on LLWindow. This permits LLWindowListener to use machinery from llui, e.g. LLUI::resolvePath(). Document planned new ["path"], ["reply"] params to "keyDown", "keyUp", "mouseDown", "mouseUp", "mouseMove" operations; document relationship between ["path"] and ["x"] and ["y"]. NEW PARAMS NOT YET IMPLEMENTED. --- indra/llwindow/CMakeLists.txt | 2 - indra/llwindow/llwindow.cpp | 9 -- indra/llwindow/llwindow.h | 2 - indra/llwindow/llwindowlistener.cpp | 234 ---------------------------------- indra/llwindow/llwindowlistener.h | 55 -------- indra/newview/CMakeLists.txt | 2 + indra/newview/llviewerwindow.cpp | 9 +- indra/newview/llviewerwindow.h | 4 +- indra/newview/llwindowlistener.cpp | 247 ++++++++++++++++++++++++++++++++++++ indra/newview/llwindowlistener.h | 55 ++++++++ 10 files changed, 315 insertions(+), 304 deletions(-) delete mode 100644 indra/llwindow/llwindowlistener.cpp delete mode 100644 indra/llwindow/llwindowlistener.h create mode 100644 indra/newview/llwindowlistener.cpp create mode 100644 indra/newview/llwindowlistener.h (limited to 'indra') diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt index 3d89867bc1..341bddfffd 100644 --- a/indra/llwindow/CMakeLists.txt +++ b/indra/llwindow/CMakeLists.txt @@ -38,7 +38,6 @@ set(llwindow_SOURCE_FILES llkeyboardheadless.cpp llwindowheadless.cpp llwindowcallbacks.cpp - llwindowlistener.cpp ) set(llwindow_HEADER_FILES @@ -48,7 +47,6 @@ set(llwindow_HEADER_FILES llkeyboardheadless.h llwindowheadless.h llwindowcallbacks.h - llwindowlistener.h ) set(viewer_SOURCE_FILES diff --git a/indra/llwindow/llwindow.cpp b/indra/llwindow/llwindow.cpp index 71a5df910d..dc3a1099b1 100644 --- a/indra/llwindow/llwindow.cpp +++ b/indra/llwindow/llwindow.cpp @@ -41,8 +41,6 @@ #include "llkeyboard.h" #include "linked_lists.h" #include "llwindowcallbacks.h" -#include "llwindowlistener.h" -#include // @@ -118,17 +116,10 @@ LLWindow::LLWindow(LLWindowCallbacks* callbacks, BOOL fullscreen, U32 flags) mFlags(flags), mHighSurrogate(0) { - // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to - // pass its value right now. Instead, pass it a nullary function that - // will, when we later need it, return the value of gKeyboard. - // boost::lambda::var() constructs such a functor on the fly. - mListener = new LLWindowListener(callbacks, boost::lambda::var(gKeyboard)); } LLWindow::~LLWindow() { - delete mListener; - mListener = NULL; } //virtual diff --git a/indra/llwindow/llwindow.h b/indra/llwindow/llwindow.h index 6bdc01ae88..e8a86a1880 100644 --- a/indra/llwindow/llwindow.h +++ b/indra/llwindow/llwindow.h @@ -36,7 +36,6 @@ class LLSplashScreen; class LLPreeditor; class LLWindowCallbacks; -class LLWindowListener; // Refer to llwindow_test in test/common/llwindow for usage example @@ -189,7 +188,6 @@ protected: BOOL mHideCursorPermanent; U32 mFlags; U16 mHighSurrogate; - LLWindowListener* mListener; // Handle a UTF-16 encoding unit received from keyboard. // Converting the series of UTF-16 encoding units to UTF-32 data, diff --git a/indra/llwindow/llwindowlistener.cpp b/indra/llwindow/llwindowlistener.cpp deleted file mode 100644 index 006aaa75e7..0000000000 --- a/indra/llwindow/llwindowlistener.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @file llwindowlistener.cpp - * @brief EventAPI interface for injecting input into LLWindow - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llwindowlistener.h" - -#include "llcoord.h" -#include "llkeyboard.h" -#include "llwindowcallbacks.h" -#include - -LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) - : LLEventAPI("LLWindow", "Inject input events into the LLWindow instance"), - mWindow(window), - mKbGetter(kbgetter) -{ - std::string keySomething = - "Given [\"keysym\"], [\"keycode\"] or [\"char\"], inject the specified "; - std::string keyExplain = - "(integer keycode values, or keysym string from any addKeyName() call in\n" - "http://hg.secondlife.com/viewer-development/src/tip/indra/llwindow/llkeyboard.cpp )"; - std::string mask = - "Specify optional [\"mask\"] as an array containing any of \"CTL\", \"ALT\",\n" - "\"SHIFT\" or \"MAC_CONTROL\"; the corresponding modifier bits will be combined\n" - "to form the mask used with the event."; - - std::string mouseSomething = - "Given [\"button\"], [\"x\"] and [\"y\"], inject the given mouse "; - std::string mouseExplain = - "(button values \"LEFT\", \"MIDDLE\", \"RIGHT\")"; - - add("keyDown", - keySomething + "keypress event.\n" + keyExplain + '\n' + mask, - &LLWindowListener::keyDown); - add("keyUp", - keySomething + "key release event.\n" + keyExplain + '\n' + mask, - &LLWindowListener::keyUp); - add("mouseDown", - mouseSomething + "click event.\n" + mouseExplain + '\n' + mask, - &LLWindowListener::mouseDown); - add("mouseUp", - mouseSomething + "release event.\n" + mouseExplain + '\n' + mask, - &LLWindowListener::mouseUp); - add("mouseMove", - std::string("Given [\"x\"] and [\"y\"], inject the given mouse movement event.\n") + - mask, - &LLWindowListener::mouseMove); - add("mouseScroll", - "Given an integer number of [\"clicks\"], inject the given mouse scroll event.\n" - "(positive clicks moves downward through typical content)", - &LLWindowListener::mouseScroll); -} - -template -class StringLookup -{ -private: - std::string mDesc; - typedef std::map Map; - Map mMap; - -public: - StringLookup(const std::string& desc): mDesc(desc) {} - - MAPPED lookup(const typename Map::key_type& key) const - { - typename Map::const_iterator found = mMap.find(key); - if (found == mMap.end()) - { - LL_WARNS("LLWindowListener") << "Unknown " << mDesc << " '" << key << "'" << LL_ENDL; - return MAPPED(); - } - return found->second; - } - -protected: - void add(const typename Map::key_type& key, const typename Map::mapped_type& value) - { - mMap.insert(typename Map::value_type(key, value)); - } -}; - -// helper for getMask() -static MASK lookupMask_(const std::string& maskname) -{ - // It's unclear to me whether MASK_MAC_CONTROL is important, but it's not - // supported by maskFromString(). Handle that specially. - if (maskname == "MAC_CONTROL") - { - return MASK_MAC_CONTROL; - } - else - { - // In case of lookup failure, return MASK_NONE, which won't affect our - // caller's OR. - MASK mask(MASK_NONE); - LLKeyboard::maskFromString(maskname, &mask); - return mask; - } -} - -static MASK getMask(const LLSD& event) -{ - LLSD masknames(event["mask"]); - if (! masknames.isArray()) - { - // If event["mask"] is a single string, perform normal lookup on it. - return lookupMask_(masknames); - } - - // Here event["mask"] is an array of mask-name strings. OR together their - // corresponding bits. - MASK mask(MASK_NONE); - for (LLSD::array_const_iterator ai(masknames.beginArray()), aend(masknames.endArray()); - ai != aend; ++ai) - { - mask |= lookupMask_(*ai); - } - return mask; -} - -static KEY getKEY(const LLSD& event) -{ - if (event.has("keysym")) - { - // Initialize to KEY_NONE; that way we can ignore the bool return from - // keyFromString() and, in the lookup-fail case, simply return KEY_NONE. - KEY key(KEY_NONE); - LLKeyboard::keyFromString(event["keysym"], &key); - return key; - } - else if (event.has("keycode")) - { - return KEY(event["keycode"].asInteger()); - } - else - { - return KEY(event["char"].asString()[0]); - } -} - -void LLWindowListener::keyDown(LLSD const & evt) -{ - mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); -} - -void LLWindowListener::keyUp(LLSD const & evt) -{ - mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); -} - -// for WhichButton -typedef BOOL (LLWindowCallbacks::*MouseFunc)(LLWindow *, LLCoordGL, MASK); -struct Actions -{ - Actions(const MouseFunc& d, const MouseFunc& u): down(d), up(u), valid(true) {} - Actions(): valid(false) {} - MouseFunc down, up; - bool valid; -}; - -struct WhichButton: public StringLookup -{ - WhichButton(): StringLookup("mouse button") - { - add("LEFT", Actions(&LLWindowCallbacks::handleMouseDown, - &LLWindowCallbacks::handleMouseUp)); - add("RIGHT", Actions(&LLWindowCallbacks::handleRightMouseDown, - &LLWindowCallbacks::handleRightMouseUp)); - add("MIDDLE", Actions(&LLWindowCallbacks::handleMiddleMouseDown, - &LLWindowCallbacks::handleMiddleMouseUp)); - } -}; -static WhichButton buttons; - -static LLCoordGL getPos(const LLSD& event) -{ - return LLCoordGL(event["x"].asInteger(), event["y"].asInteger()); -} - -void LLWindowListener::mouseDown(LLSD const & evt) -{ - Actions actions(buttons.lookup(evt["button"])); - if (actions.valid) - { - (mWindow->*(actions.down))(NULL, getPos(evt), getMask(evt)); - } -} - -void LLWindowListener::mouseUp(LLSD const & evt) -{ - Actions actions(buttons.lookup(evt["button"])); - if (actions.valid) - { - (mWindow->*(actions.up))(NULL, getPos(evt), getMask(evt)); - } -} - -void LLWindowListener::mouseMove(LLSD const & evt) -{ - mWindow->handleMouseMove(NULL, getPos(evt), getMask(evt)); -} - -void LLWindowListener::mouseScroll(LLSD const & evt) -{ - S32 clicks = evt["clicks"].asInteger(); - - mWindow->handleScrollWheel(NULL, clicks); -} - diff --git a/indra/llwindow/llwindowlistener.h b/indra/llwindow/llwindowlistener.h deleted file mode 100644 index 74e577ff93..0000000000 --- a/indra/llwindow/llwindowlistener.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @file llwindowlistener.h - * @brief EventAPI interface for injecting input into LLWindow - * - * $LicenseInfo:firstyear=2001&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLWINDOWLISTENER_H -#define LL_LLWINDOWLISTENER_H - -#include "lleventapi.h" -#include - -class LLKeyboard; -class LLWindowCallbacks; - -class LLWindowListener : public LLEventAPI -{ -public: - typedef boost::function KeyboardGetter; - LLWindowListener(LLWindowCallbacks * window, const KeyboardGetter& kbgetter); - - void keyDown(LLSD const & evt); - void keyUp(LLSD const & evt); - void mouseDown(LLSD const & evt); - void mouseUp(LLSD const & evt); - void mouseMove(LLSD const & evt); - void mouseScroll(LLSD const & evt); - -private: - LLWindowCallbacks * mWindow; - KeyboardGetter mKbGetter; -}; - - -#endif // LL_LLWINDOWLISTENER_H diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 935dd2e887..bd080f2ac4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -599,6 +599,7 @@ set(viewer_SOURCE_FILES llweb.cpp llwebsharing.cpp llwind.cpp + llwindowlistener.cpp llwlanimator.cpp llwldaycycle.cpp llwlhandlers.cpp @@ -1153,6 +1154,7 @@ set(viewer_HEADER_FILES llweb.h llwebsharing.h llwind.h + llwindowlistener.h llwlanimator.h llwldaycycle.h llwlhandlers.h diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 988c4ed1a2..0501b61592 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "llagent.h" #include "llagentcamera.h" @@ -198,6 +199,7 @@ #include "llfloaternotificationsconsole.h" #include "llnearbychat.h" +#include "llwindowlistener.h" #include "llviewerwindowlistener.h" #include "llpaneltopinfobar.h" @@ -1552,7 +1554,12 @@ LLViewerWindow::LLViewerWindow( mResDirty(false), mStatesDirty(false), mCurrResolutionIndex(0), - mViewerWindowListener(new LLViewerWindowListener(this)), + // gKeyboard is still NULL, so it doesn't do LLWindowListener any good to + // pass its value right now. Instead, pass it a nullary function that + // will, when we later need it, return the value of gKeyboard. + // boost::lambda::var() constructs such a functor on the fly. + mWindowListener(new LLWindowListener(this, boost::lambda::var(gKeyboard))), + mViewerWindowListener(new LLViewerWindowListener(this)), mProgressView(NULL) { LLNotificationChannel::buildChannel("VW_alerts", "Visible", LLNotificationFilters::filterBy(&LLNotification::getType, "alert")); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ff49ed1f62..48599ebb00 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -62,6 +62,7 @@ class LLImageFormatted; class LLHUDIcon; class LLWindow; class LLRootView; +class LLWindowListener; class LLViewerWindowListener; class LLPopupView; @@ -455,7 +456,8 @@ protected: bool mStatesDirty; U32 mCurrResolutionIndex; - boost::scoped_ptr mViewerWindowListener; + boost::scoped_ptr mWindowListener; + boost::scoped_ptr mViewerWindowListener; protected: static std::string sSnapshotBaseName; diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp new file mode 100644 index 0000000000..e5deaa42cf --- /dev/null +++ b/indra/newview/llwindowlistener.cpp @@ -0,0 +1,247 @@ +/** + * @file llwindowlistener.cpp + * @brief EventAPI interface for injecting input into LLWindow + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "linden_common.h" + +#include "llwindowlistener.h" + +#include "llcoord.h" +#include "llkeyboard.h" +#include "llwindowcallbacks.h" +#include "llui.h" +#include + +LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) + : LLEventAPI("LLWindow", "Inject input events into the LLWindow instance"), + mWindow(window), + mKbGetter(kbgetter) +{ + std::string keySomething = + "Given [\"keysym\"], [\"keycode\"] or [\"char\"], inject the specified "; + std::string keyExplain = + "(integer keycode values, or keysym string from any addKeyName() call in\n" + "http://hg.secondlife.com/viewer-development/src/tip/indra/llwindow/llkeyboard.cpp )\n"; + std::string mask = + "Specify optional [\"mask\"] as an array containing any of \"CTL\", \"ALT\",\n" + "\"SHIFT\" or \"MAC_CONTROL\"; the corresponding modifier bits will be combined\n" + "to form the mask used with the event."; + + std::string given = "Given "; + std::string mouseParams = + "optional [\"path\"], optional [\"x\"] and [\"y\"], inject the requested mouse "; + std::string buttonParams = + std::string("[\"button\"], ") + mouseParams; + std::string buttonExplain = + "(button values \"LEFT\", \"MIDDLE\", \"RIGHT\")\n"; + std::string paramsExplain = + "[\"path\"] is as for LLUI::resolvePath(), described in\n" + "http://hg.secondlife.com/viewer-development/src/tip/indra/llui/llui.h\n" + "If you omit [\"path\"], you must specify both [\"x\"] and [\"y\"].\n" + "If you specify [\"path\"] without both [\"x\"] and [\"y\"], will synthesize (x, y)\n" + "in the center of the LLView selected by [\"path\"].\n" + "You may specify [\"path\"] with both [\"x\"] and [\"y\"], will use your (x, y).\n" + "This may cause the LLView selected by [\"path\"] to reject the event.\n" + "Optional [\"reply\"] requests a reply event on the named LLEventPump.\n" + "reply[\"error\"] isUndefined (None) on success, else an explanatory message.\n"; + + add("keyDown", + keySomething + "keypress event.\n" + keyExplain + mask, + &LLWindowListener::keyDown); + add("keyUp", + keySomething + "key release event.\n" + keyExplain + mask, + &LLWindowListener::keyUp); + add("mouseDown", + given + buttonParams + "click event.\n" + buttonExplain + paramsExplain + mask, + &LLWindowListener::mouseDown); + add("mouseUp", + given + buttonParams + "release event.\n" + buttonExplain + paramsExplain + mask, + &LLWindowListener::mouseUp); + add("mouseMove", + given + mouseParams + "movement event.\n" + paramsExplain + mask, + &LLWindowListener::mouseMove); + add("mouseScroll", + "Given an integer number of [\"clicks\"], inject the requested mouse scroll event.\n" + "(positive clicks moves downward through typical content)", + &LLWindowListener::mouseScroll); +} + +template +class StringLookup +{ +private: + std::string mDesc; + typedef std::map Map; + Map mMap; + +public: + StringLookup(const std::string& desc): mDesc(desc) {} + + MAPPED lookup(const typename Map::key_type& key) const + { + typename Map::const_iterator found = mMap.find(key); + if (found == mMap.end()) + { + LL_WARNS("LLWindowListener") << "Unknown " << mDesc << " '" << key << "'" << LL_ENDL; + return MAPPED(); + } + return found->second; + } + +protected: + void add(const typename Map::key_type& key, const typename Map::mapped_type& value) + { + mMap.insert(typename Map::value_type(key, value)); + } +}; + +// helper for getMask() +static MASK lookupMask_(const std::string& maskname) +{ + // It's unclear to me whether MASK_MAC_CONTROL is important, but it's not + // supported by maskFromString(). Handle that specially. + if (maskname == "MAC_CONTROL") + { + return MASK_MAC_CONTROL; + } + else + { + // In case of lookup failure, return MASK_NONE, which won't affect our + // caller's OR. + MASK mask(MASK_NONE); + LLKeyboard::maskFromString(maskname, &mask); + return mask; + } +} + +static MASK getMask(const LLSD& event) +{ + LLSD masknames(event["mask"]); + if (! masknames.isArray()) + { + // If event["mask"] is a single string, perform normal lookup on it. + return lookupMask_(masknames); + } + + // Here event["mask"] is an array of mask-name strings. OR together their + // corresponding bits. + MASK mask(MASK_NONE); + for (LLSD::array_const_iterator ai(masknames.beginArray()), aend(masknames.endArray()); + ai != aend; ++ai) + { + mask |= lookupMask_(*ai); + } + return mask; +} + +static KEY getKEY(const LLSD& event) +{ + if (event.has("keysym")) + { + // Initialize to KEY_NONE; that way we can ignore the bool return from + // keyFromString() and, in the lookup-fail case, simply return KEY_NONE. + KEY key(KEY_NONE); + LLKeyboard::keyFromString(event["keysym"], &key); + return key; + } + else if (event.has("keycode")) + { + return KEY(event["keycode"].asInteger()); + } + else + { + return KEY(event["char"].asString()[0]); + } +} + +void LLWindowListener::keyDown(LLSD const & evt) +{ + mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); +} + +void LLWindowListener::keyUp(LLSD const & evt) +{ + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); +} + +// for WhichButton +typedef BOOL (LLWindowCallbacks::*MouseFunc)(LLWindow *, LLCoordGL, MASK); +struct Actions +{ + Actions(const MouseFunc& d, const MouseFunc& u): down(d), up(u), valid(true) {} + Actions(): valid(false) {} + MouseFunc down, up; + bool valid; +}; + +struct WhichButton: public StringLookup +{ + WhichButton(): StringLookup("mouse button") + { + add("LEFT", Actions(&LLWindowCallbacks::handleMouseDown, + &LLWindowCallbacks::handleMouseUp)); + add("RIGHT", Actions(&LLWindowCallbacks::handleRightMouseDown, + &LLWindowCallbacks::handleRightMouseUp)); + add("MIDDLE", Actions(&LLWindowCallbacks::handleMiddleMouseDown, + &LLWindowCallbacks::handleMiddleMouseUp)); + } +}; +static WhichButton buttons; + +static LLCoordGL getPos(const LLSD& event) +{ + return LLCoordGL(event["x"].asInteger(), event["y"].asInteger()); +} + +void LLWindowListener::mouseDown(LLSD const & evt) +{ + Actions actions(buttons.lookup(evt["button"])); + if (actions.valid) + { + (mWindow->*(actions.down))(NULL, getPos(evt), getMask(evt)); + } +} + +void LLWindowListener::mouseUp(LLSD const & evt) +{ + Actions actions(buttons.lookup(evt["button"])); + if (actions.valid) + { + (mWindow->*(actions.up))(NULL, getPos(evt), getMask(evt)); + } +} + +void LLWindowListener::mouseMove(LLSD const & evt) +{ + mWindow->handleMouseMove(NULL, getPos(evt), getMask(evt)); +} + +void LLWindowListener::mouseScroll(LLSD const & evt) +{ + S32 clicks = evt["clicks"].asInteger(); + + mWindow->handleScrollWheel(NULL, clicks); +} + diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h new file mode 100644 index 0000000000..74e577ff93 --- /dev/null +++ b/indra/newview/llwindowlistener.h @@ -0,0 +1,55 @@ +/** + * @file llwindowlistener.h + * @brief EventAPI interface for injecting input into LLWindow + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_LLWINDOWLISTENER_H +#define LL_LLWINDOWLISTENER_H + +#include "lleventapi.h" +#include + +class LLKeyboard; +class LLWindowCallbacks; + +class LLWindowListener : public LLEventAPI +{ +public: + typedef boost::function KeyboardGetter; + LLWindowListener(LLWindowCallbacks * window, const KeyboardGetter& kbgetter); + + void keyDown(LLSD const & evt); + void keyUp(LLSD const & evt); + void mouseDown(LLSD const & evt); + void mouseUp(LLSD const & evt); + void mouseMove(LLSD const & evt); + void mouseScroll(LLSD const & evt); + +private: + LLWindowCallbacks * mWindow; + KeyboardGetter mKbGetter; +}; + + +#endif // LL_LLWINDOWLISTENER_H -- cgit v1.2.3 From 1d31559b30a32c4ebfde7dc2c42baef840be7c4d Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Fri, 26 Aug 2011 15:06:14 -0500 Subject: implement path option for key events. --- indra/newview/llwindowlistener.cpp | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index e5deaa42cf..3d756ef9b9 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -29,9 +29,13 @@ #include "llwindowlistener.h" #include "llcoord.h" +#include "llfocusmgr.h" #include "llkeyboard.h" #include "llwindowcallbacks.h" #include "llui.h" +#include "llview.h" +#include "llviewerwindow.h" +#include "llrootview.h" #include LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) @@ -117,8 +121,10 @@ protected: } }; +namespace { + // helper for getMask() -static MASK lookupMask_(const std::string& maskname) +MASK lookupMask_(const std::string& maskname) { // It's unclear to me whether MASK_MAC_CONTROL is important, but it's not // supported by maskFromString(). Handle that specially. @@ -136,7 +142,7 @@ static MASK lookupMask_(const std::string& maskname) } } -static MASK getMask(const LLSD& event) +MASK getMask(const LLSD& event) { LLSD masknames(event["mask"]); if (! masknames.isArray()) @@ -156,7 +162,7 @@ static MASK getMask(const LLSD& event) return mask; } -static KEY getKEY(const LLSD& event) +KEY getKEY(const LLSD& event) { if (event.has("keysym")) { @@ -176,13 +182,36 @@ static KEY getKEY(const LLSD& event) } } +} // namespace + void LLWindowListener::keyDown(LLSD const & evt) { - mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); + if (evt.has("path")) + { + LLView * target_view = + LLUI::resolvePath(gViewerWindow->getRootView(), evt["path"]); + if ((target_view != 0) && target_view->isAvailable()) + { + gFocusMgr.setKeyboardFocus(target_view); + KEY key = getKEY(evt); + MASK mask = getMask(evt); + if (!target_view->handleKey(key, mask, true)) target_view->handleUnicodeChar(key, true); + } + else + { + ; // TODO: Don't silently fail if target not available. + } + } + else + { + mKbGetter()->handleTranslatedKeyDown(getKEY(evt), getMask(evt)); + } } void LLWindowListener::keyUp(LLSD const & evt) { + if (evt.has("path")) return; // LLView only handles key down. + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); } -- cgit v1.2.3 From 34a620523a7f4511c8f008f2e9a9428f41281480 Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Mon, 29 Aug 2011 13:27:17 -0500 Subject: a better way to inject key events. --- indra/newview/llwindowlistener.cpp | 27 ++++++++++++++++++++++----- indra/newview/llwindowlistener.h | 6 +++--- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 3d756ef9b9..4cadc8773d 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -35,10 +35,11 @@ #include "llui.h" #include "llview.h" #include "llviewerwindow.h" +#include "llviewerkeyboard.h" #include "llrootview.h" #include -LLWindowListener::LLWindowListener(LLWindowCallbacks *window, const KeyboardGetter& kbgetter) +LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& kbgetter) : LLEventAPI("LLWindow", "Inject input events into the LLWindow instance"), mWindow(window), mKbGetter(kbgetter) @@ -195,7 +196,8 @@ void LLWindowListener::keyDown(LLSD const & evt) gFocusMgr.setKeyboardFocus(target_view); KEY key = getKEY(evt); MASK mask = getMask(evt); - if (!target_view->handleKey(key, mask, true)) target_view->handleUnicodeChar(key, true); + gViewerKeyboard.handleKey(key, mask, false); + if(key < 0x80) mWindow->handleUnicodeChar(key, mask); } else { @@ -210,9 +212,24 @@ void LLWindowListener::keyDown(LLSD const & evt) void LLWindowListener::keyUp(LLSD const & evt) { - if (evt.has("path")) return; // LLView only handles key down. - - mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); + if (evt.has("path")) + { + LLView * target_view = + LLUI::resolvePath(gViewerWindow->getRootView(), evt["path"]); + if ((target_view != 0) && target_view->isAvailable()) + { + gFocusMgr.setKeyboardFocus(target_view); + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); + } + else + { + ; // TODO: Don't silently fail if target not available. + } + } + else + { + mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); + } } // for WhichButton diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h index 74e577ff93..26adff35ff 100644 --- a/indra/newview/llwindowlistener.h +++ b/indra/newview/llwindowlistener.h @@ -31,13 +31,13 @@ #include class LLKeyboard; -class LLWindowCallbacks; +class LLViewerWindow; class LLWindowListener : public LLEventAPI { public: typedef boost::function KeyboardGetter; - LLWindowListener(LLWindowCallbacks * window, const KeyboardGetter& kbgetter); + LLWindowListener(LLViewerWindow * window, const KeyboardGetter& kbgetter); void keyDown(LLSD const & evt); void keyUp(LLSD const & evt); @@ -47,7 +47,7 @@ public: void mouseScroll(LLSD const & evt); private: - LLWindowCallbacks * mWindow; + LLViewerWindow * mWindow; KeyboardGetter mKbGetter; }; -- cgit v1.2.3 From f08d7fba9f2134a687169d8da478a44bdbe16955 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Aug 2011 15:57:32 -0400 Subject: CHOP-763: Implement widget-pathname-based routing for mouse events. Send mouseDown(), mouseUp(), mouseMove() through static mouseEvent() helper function. Process new optional ["path"] param, validating corresponding LLView and capturing certain information about it for caller. Synthesize (x, y) pos if need be. Use LLView::TemporaryDrilldownFunc and llview::TargetEvent to temporarily hijack normal LLView mouse-event propagation. Define Response helper class to capture LLSD blob about the current request and ensure it gets sent on return. --- indra/newview/llwindowlistener.cpp | 199 ++++++++++++++++++++++++++++++++++--- 1 file changed, 183 insertions(+), 16 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 4cadc8773d..84126b7738 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -34,10 +34,19 @@ #include "llwindowcallbacks.h" #include "llui.h" #include "llview.h" +#include "llviewinject.h" #include "llviewerwindow.h" #include "llviewerkeyboard.h" #include "llrootview.h" +#include "llsdutil.h" +#include "stringize.h" +#include #include +#include +#include +#include + +namespace bll = boost::lambda; LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& kbgetter) : LLEventAPI("LLWindow", "Inject input events into the LLWindow instance"), @@ -233,12 +242,12 @@ void LLWindowListener::keyUp(LLSD const & evt) } // for WhichButton -typedef BOOL (LLWindowCallbacks::*MouseFunc)(LLWindow *, LLCoordGL, MASK); +typedef BOOL (LLWindowCallbacks::*MouseMethod)(LLWindow *, LLCoordGL, MASK); struct Actions { - Actions(const MouseFunc& d, const MouseFunc& u): down(d), up(u), valid(true) {} + Actions(const MouseMethod& d, const MouseMethod& u): down(d), up(u), valid(true) {} Actions(): valid(false) {} - MouseFunc down, up; + MouseMethod down, up; bool valid; }; @@ -256,38 +265,196 @@ struct WhichButton: public StringLookup }; static WhichButton buttons; -static LLCoordGL getPos(const LLSD& event) +struct Response +{ + Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey="reply"): + mResp(seed), + mReq(request), + mKey(replyKey) + {} + + ~Response() + { + // When you instantiate a stack Response object, if the original + // request requested a reply, send it when we leave this block, no + // matter how. + sendReply(mResp, mReq, mKey); + } + + void warn(const std::string& warning) + { + LL_WARNS("LLWindowListener") << warning << LL_ENDL; + mResp["warnings"].append(warning); + } + + void error(const std::string& error) + { + // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut + // down altogether. + LL_WARNS("LLWindowListener") << error << LL_ENDL; + + mResp["error"] = error; + } + + // set other keys... + LLSD& operator[](const LLSD::String& key) { return mResp[key]; } + + LLSD mResp, mReq; + LLSD::String mKey; +}; + +typedef boost::function MouseFunc; + +static void mouseEvent(const MouseFunc& func, const LLSD& request) { - return LLCoordGL(event["x"].asInteger(), event["y"].asInteger()); + // Ensure we send response + Response response(LLSD(), request); + // We haven't yet established whether the incoming request has "x" and "y", + // but capture this anyway, with 0 for omitted values. + LLCoordGL pos(request["x"].asInteger(), request["y"].asInteger()); + bool has_pos(request.has("x") && request.has("y")); + + boost::scoped_ptr tempfunc; + + // Documentation for mouseDown(), mouseUp() and mouseMove() claims you + // must either specify ["path"], or both of ["x"] and ["y"]. You MAY + // specify all. Let's say that passing "path" as an empty string is + // equivalent to not passing it at all. + std::string path(request["path"]); + if (path.empty()) + { + // Without "path", you must specify both "x" and "y". + if (! has_pos) + { + return response.error(STRINGIZE(request["op"].asString() << " request " + "without \"path\" must specify both \"x\" and \"y\": " + << request)); + } + } + else // ! path.empty() + { + LLView* root = LLUI::getRootView(); + LLView* target = LLUI::resolvePath(root, path); + if (! target) + { + return response.error(STRINGIZE(request["op"].asString() << " request " + "specified invalid \"path\": '" << path << "'")); + return; + } + + // Get info about this LLView* for when we send response. + response["path"] = target->getPathname(); + response["class"] = typeid(*target).name(); + bool visible_chain(target->isInVisibleChain()); + bool enabled_chain(target->isInEnabledChain()); + response["visible"] = target->getVisible(); + response["visible_chain"] = visible_chain; + response["enabled"] = target->getEnabled(); + response["enabled_chain"] = enabled_chain; + response["available"] = target->isAvailable(); + // Don't show caller the LLView's own relative rectangle; that only + // tells its dimensions. Provide actual location on screen. + LLRect rect(target->calcScreenRect()); + response["rect"] = LLSDMap("left", rect.mLeft)("top", rect.mTop)("right", rect.mRight)("bottom", rect.mBottom); + + // The intent of this test is to prevent trying to drill down to a + // widget in a hidden floater, or on a tab that's not current, etc. + if (! visible_chain) + { + return response.error(STRINGIZE(request["op"].asString() << " request " + "specified \"path\" not currently visible: '" + << path << "'")); + } + + // This test isn't folded in with the above error case since you can + // (e.g.) pop up a tooltip even for a disabled widget. + if (! enabled_chain) + { + response.warn(STRINGIZE(request["op"].asString() << " request " + "specified \"path\" not currently enabled: '" + << path << "'")); + } + + if (! has_pos) + { + pos.set(rect.getCenterX(), rect.getCenterY()); + // nonstandard warning tactic: probably usual case; we want event + // sender to know synthesized (x, y), but maybe don't need to log? + response["warnings"].append(STRINGIZE("using center point (" + << pos.mX << ", " << pos.mY << ")")); + } + + // recursive childFromPoint() should give us the frontmost, leafmost + // widget at the specified (x, y). + LLView* frontmost = root->childFromPoint(pos.mX, pos.mY, true); + if (frontmost != target) + { + response.warn(STRINGIZE(request["op"].asString() << " request " + "specified \"path\" = '" << path + << "', but frontmost LLView at (" << pos.mX << ", " << pos.mY + << ") is '" << frontmost->getPathname() << "'")); + } + + // Instantiate a TemporaryDrilldownFunc to route incoming mouse events + // to the target LLView*. But put it on the heap since "path" is + // optional. Nonetheless, manage it with a boost::scoped_ptr so it + // will be destroyed when we leave. + tempfunc.reset(new LLView::TemporaryDrilldownFunc(llview::TargetEvent(target))); + } + + // The question of whether the requested LLView actually handled the + // specified event is important enough, and its handling unclear enough, + // to warrant a separate response attribute. Instead of deciding here to + // make it a warning, or an error, let caller decide. + response["handled"] = func(pos, getMask(request)); + + // On exiting this scope, response will send, tempfunc will restore the + // normal pointInView(x, y) containment logic, etc. } -void LLWindowListener::mouseDown(LLSD const & evt) +void LLWindowListener::mouseDown(LLSD const & request) { - Actions actions(buttons.lookup(evt["button"])); + Actions actions(buttons.lookup(request["button"])); if (actions.valid) { - (mWindow->*(actions.down))(NULL, getPos(evt), getMask(evt)); + // Normally you can pass NULL to an LLWindow* without compiler + // complaint, but going through boost::lambda::bind() evidently + // bypasses that special case: it only knows you're trying to pass an + // int to a pointer. Explicitly cast NULL to the desired pointer type. + mouseEvent(bll::bind(actions.down, mWindow, + static_cast(NULL), bll::_1, bll::_2), + request); } } -void LLWindowListener::mouseUp(LLSD const & evt) +void LLWindowListener::mouseUp(LLSD const & request) { - Actions actions(buttons.lookup(evt["button"])); + Actions actions(buttons.lookup(request["button"])); if (actions.valid) { - (mWindow->*(actions.up))(NULL, getPos(evt), getMask(evt)); + mouseEvent(bll::bind(actions.up, mWindow, + static_cast(NULL), bll::_1, bll::_2), + request); } } -void LLWindowListener::mouseMove(LLSD const & evt) +void LLWindowListener::mouseMove(LLSD const & request) { - mWindow->handleMouseMove(NULL, getPos(evt), getMask(evt)); + // We want to call the same central mouseEvent() routine for + // handleMouseMove() as for button clicks. But handleMouseMove() returns + // void, whereas mouseEvent() accepts a function returning bool -- and + // uses that bool return. Use (void-lambda-expression, true) to construct + // a callable that returns bool anyway. Pass 'true' because we expect that + // our caller will usually treat 'false' as a problem. + mouseEvent((bll::bind(&LLWindowCallbacks::handleMouseMove, mWindow, + static_cast(NULL), bll::_1, bll::_2), + true), + request); } -void LLWindowListener::mouseScroll(LLSD const & evt) +void LLWindowListener::mouseScroll(LLSD const & request) { - S32 clicks = evt["clicks"].asInteger(); + S32 clicks = request["clicks"].asInteger(); mWindow->handleScrollWheel(NULL, clicks); } - -- cgit v1.2.3 From 5fb224bb8196e77259bef2a0ef60e82533c358a2 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 30 Aug 2011 09:52:25 -0400 Subject: CHOP-763: make sendReply() treat replyKey as optional. It's not worth bothering to tweak reply LLSD or attempt to send it if the incoming request has no replyKey, in effect not requesting a reply. This supports LLEventAPI operations for which the caller might or might not care about a reply, invoked using either send() (fire and forget) or request() (send request, wait for response). This logic should be central, instead of having to perform that test in every caller that cares. The major alternative would have been to treat missing replyKey as an error (whether LL_ERRS or exception). But since there's already a mechanism by which an LLEventAPI operation method can stipulate its replyKey as required, at this level we can let it be optional. --- indra/llcommon/llevents.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/llevents.cpp b/indra/llcommon/llevents.cpp index ff03506e84..db1ea4792b 100644 --- a/indra/llcommon/llevents.cpp +++ b/indra/llcommon/llevents.cpp @@ -591,6 +591,17 @@ void LLReqID::stamp(LLSD& response) const bool sendReply(const LLSD& reply, const LLSD& request, const std::string& replyKey) { + // If the original request has no value for replyKey, it's pointless to + // construct or send a reply event: on which LLEventPump should we send + // it? Allow that to be optional: if the caller wants to require replyKey, + // it can so specify when registering the operation method. + if (! request.has(replyKey)) + { + return false; + } + + // Here the request definitely contains replyKey; reasonable to proceed. + // Copy 'reply' to modify it. LLSD newreply(reply); // Get the ["reqid"] element from request -- cgit v1.2.3 From 6e8ba7e1179c0ac8c3a085e010992ea91fb15114 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 30 Aug 2011 09:53:43 -0400 Subject: CHOP-763: Introduce LLView::getPathname(). --- indra/llui/llview.cpp | 19 +++++++++++++++++++ indra/llui/llview.h | 1 + 2 files changed, 20 insertions(+) (limited to 'indra') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 56b09791a4..474b568a87 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -31,6 +31,7 @@ #include "llview.h" #include +#include #include #include #include @@ -430,6 +431,24 @@ BOOL LLView::isInEnabledChain() const return enabled; } +static void buildPathname(std::ostream& out, const LLView* view) +{ + if (view) + { + // While we're not yet at root level, keep recurring towards top + buildPathname(out, view->getParent()); + } + // Build pathname into ostream on the way back from recursion. + out << '/' << view->getName(); +} + +std::string LLView::getPathname() const +{ + std::ostringstream out; + buildPathname(out, this); + return out.str(); +} + // virtual BOOL LLView::canFocusChildren() const { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 67634938fb..11f25bcd7f 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -444,6 +444,7 @@ public: virtual void onMouseEnter(S32 x, S32 y, MASK mask); virtual void onMouseLeave(S32 x, S32 y, MASK mask); + std::string getPathname() const; template T* findChild(const std::string& name, BOOL recurse = TRUE) const { -- cgit v1.2.3 From 12dbf4c7b4a7bf64acaa7207c8bceffb64f021b3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 30 Aug 2011 11:30:51 -0400 Subject: CHOP-763: Add Windows magic precompiled header #include. --- indra/newview/llwindowlistener.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 84126b7738..8d794e5380 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -24,6 +24,7 @@ * $/LicenseInfo$ */ +#include "llviewerprecompiledheaders.h" #include "linden_common.h" #include "llwindowlistener.h" -- cgit v1.2.3 From f08de06bf223c9876bd7495e36f61b19022938a7 Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Tue, 30 Aug 2011 13:30:18 -0500 Subject: fix crash bug; exclude root from path. --- indra/llui/llview.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'indra') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 474b568a87..0c8e3bace4 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -433,13 +433,20 @@ BOOL LLView::isInEnabledChain() const static void buildPathname(std::ostream& out, const LLView* view) { - if (view) + if (view == 0) return; + + if (view->getParent() != 0) { - // While we're not yet at root level, keep recurring towards top buildPathname(out, view->getParent()); + + // Build pathname into ostream on the way back from recursion. + out << '/' << view->getName(); } - // Build pathname into ostream on the way back from recursion. - out << '/' << view->getName(); + else + { + ; // Don't include root in the path. + } + } std::string LLView::getPathname() const -- cgit v1.2.3 From 713aa42f61d6d5791b26f56a73bd7cf7abb76f0d Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Tue, 30 Aug 2011 13:37:10 -0500 Subject: add responses to key events. --- indra/newview/llwindowlistener.cpp | 142 ++++++++++++++++++++++--------------- 1 file changed, 85 insertions(+), 57 deletions(-) (limited to 'indra') diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 8d794e5380..84a490f661 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -134,6 +134,57 @@ protected: namespace { +class Response +{ +public: + Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey="reply"): + mResp(seed), + mReq(request), + mKey(replyKey) + {} + + ~Response() + { + // When you instantiate a stack Response object, if the original + // request requested a reply, send it when we leave this block, no + // matter how. + sendReply(mResp, mReq, mKey); + } + + void warn(const std::string& warning) + { + LL_WARNS("LLWindowListener") << warning << LL_ENDL; + mResp["warnings"].append(warning); + } + + void error(const std::string& error) + { + // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut + // down altogether. + LL_WARNS("LLWindowListener") << error << LL_ENDL; + + mResp["error"] = error; + } + + // set other keys... + LLSD& operator[](const LLSD::String& key) { return mResp[key]; } + + LLSD mResp, mReq; + LLSD::String mKey; +}; + +void insertViewInformation(Response & response, LLView * target) +{ + // Get info about this LLView* for when we send response. + response["path"] = target->getPathname(); + response["class"] = typeid(*target).name(); + response["visible"] = target->getVisible(); + response["visible_chain"] = target->isInVisibleChain(); + response["enabled"] = target->getEnabled(); + response["enabled_chain"] = target->isInEnabledChain(); + response["available"] = target->isAvailable(); +} + // helper for getMask() MASK lookupMask_(const std::string& maskname) { @@ -197,12 +248,22 @@ KEY getKEY(const LLSD& event) void LLWindowListener::keyDown(LLSD const & evt) { + Response response(LLSD(), evt); + if (evt.has("path")) { + std::string path(evt["path"]); LLView * target_view = - LLUI::resolvePath(gViewerWindow->getRootView(), evt["path"]); - if ((target_view != 0) && target_view->isAvailable()) + LLUI::resolvePath(gViewerWindow->getRootView(), path); + if (target_view == 0) + { + response.error(STRINGIZE(evt["op"].asString() << " request " + "specified invalid \"path\": '" << path << "'")); + } + else if(target_view->isAvailable()) { + insertViewInformation(response, target_view); + gFocusMgr.setKeyboardFocus(target_view); KEY key = getKEY(evt); MASK mask = getMask(evt); @@ -211,7 +272,9 @@ void LLWindowListener::keyDown(LLSD const & evt) } else { - ; // TODO: Don't silently fail if target not available. + response.error(STRINGIZE(evt["op"].asString() << " request " + "element specified byt \"path\": '" << path << "'" + << " is not visible")); } } else @@ -222,18 +285,30 @@ void LLWindowListener::keyDown(LLSD const & evt) void LLWindowListener::keyUp(LLSD const & evt) { + Response response(LLSD(), evt); + if (evt.has("path")) { + std::string path(evt["path"]); LLView * target_view = - LLUI::resolvePath(gViewerWindow->getRootView(), evt["path"]); - if ((target_view != 0) && target_view->isAvailable()) + LLUI::resolvePath(gViewerWindow->getRootView(), path); + if (target_view == 0 ) + { + response.error(STRINGIZE(evt["op"].asString() << " request " + "specified invalid \"path\": '" << path << "'")); + } + else if (target_view->isAvailable()) { + insertViewInformation(response, target_view); + gFocusMgr.setKeyboardFocus(target_view); mKbGetter()->handleTranslatedKeyUp(getKEY(evt), getMask(evt)); } else { - ; // TODO: Don't silently fail if target not available. + response.error(STRINGIZE(evt["op"].asString() << " request " + "element specified byt \"path\": '" << path << "'" + << " is not visible")); } } else @@ -266,44 +341,6 @@ struct WhichButton: public StringLookup }; static WhichButton buttons; -struct Response -{ - Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey="reply"): - mResp(seed), - mReq(request), - mKey(replyKey) - {} - - ~Response() - { - // When you instantiate a stack Response object, if the original - // request requested a reply, send it when we leave this block, no - // matter how. - sendReply(mResp, mReq, mKey); - } - - void warn(const std::string& warning) - { - LL_WARNS("LLWindowListener") << warning << LL_ENDL; - mResp["warnings"].append(warning); - } - - void error(const std::string& error) - { - // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut - // down altogether. - LL_WARNS("LLWindowListener") << error << LL_ENDL; - - mResp["error"] = error; - } - - // set other keys... - LLSD& operator[](const LLSD::String& key) { return mResp[key]; } - - LLSD mResp, mReq; - LLSD::String mKey; -}; - typedef boost::function MouseFunc; static void mouseEvent(const MouseFunc& func, const LLSD& request) @@ -340,19 +377,10 @@ static void mouseEvent(const MouseFunc& func, const LLSD& request) { return response.error(STRINGIZE(request["op"].asString() << " request " "specified invalid \"path\": '" << path << "'")); - return; } - // Get info about this LLView* for when we send response. - response["path"] = target->getPathname(); - response["class"] = typeid(*target).name(); - bool visible_chain(target->isInVisibleChain()); - bool enabled_chain(target->isInEnabledChain()); - response["visible"] = target->getVisible(); - response["visible_chain"] = visible_chain; - response["enabled"] = target->getEnabled(); - response["enabled_chain"] = enabled_chain; - response["available"] = target->isAvailable(); + insertViewInformation(response, target); + // Don't show caller the LLView's own relative rectangle; that only // tells its dimensions. Provide actual location on screen. LLRect rect(target->calcScreenRect()); @@ -360,7 +388,7 @@ static void mouseEvent(const MouseFunc& func, const LLSD& request) // The intent of this test is to prevent trying to drill down to a // widget in a hidden floater, or on a tab that's not current, etc. - if (! visible_chain) + if (! target->isInVisibleChain()) { return response.error(STRINGIZE(request["op"].asString() << " request " "specified \"path\" not currently visible: '" @@ -369,7 +397,7 @@ static void mouseEvent(const MouseFunc& func, const LLSD& request) // This test isn't folded in with the above error case since you can // (e.g.) pop up a tooltip even for a disabled widget. - if (! enabled_chain) + if (! target->isInEnabledChain()) { response.warn(STRINGIZE(request["op"].asString() << " request " "specified \"path\" not currently enabled: '" -- cgit v1.2.3 From 71aec7439c1a8027880ac06d99f923ab8fa7111b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 30 Aug 2011 15:22:44 -0400 Subject: CHOP-763: Introduce static LLView::getPathname(LLView*). Use it for LLWindowListener to safely report an LLView* which might be NULL. --- indra/llui/llview.cpp | 27 ++++++++++++++++----------- indra/llui/llview.h | 2 ++ indra/newview/llwindowlistener.cpp | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'indra') diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 0c8e3bace4..77abb1c6bf 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -433,20 +433,15 @@ BOOL LLView::isInEnabledChain() const static void buildPathname(std::ostream& out, const LLView* view) { - if (view == 0) return; - - if (view->getParent() != 0) + if (! (view && view->getParent())) { - buildPathname(out, view->getParent()); - - // Build pathname into ostream on the way back from recursion. - out << '/' << view->getName(); - } - else - { - ; // Don't include root in the path. + return; // Don't include root in the path. } + buildPathname(out, view->getParent()); + + // Build pathname into ostream on the way back from recursion. + out << '/' << view->getName(); } std::string LLView::getPathname() const @@ -456,6 +451,16 @@ std::string LLView::getPathname() const return out.str(); } +//static +std::string LLView::getPathname(const LLView* view) +{ + if (! view) + { + return "NULL"; + } + return view->getPathname(); +} + // virtual BOOL LLView::canFocusChildren() const { diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 11f25bcd7f..97151c4fb4 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -445,6 +445,8 @@ public: virtual void onMouseLeave(S32 x, S32 y, MASK mask); std::string getPathname() const; + // static method handles NULL pointer too + static std::string getPathname(const LLView*); template T* findChild(const std::string& name, BOOL recurse = TRUE) const { diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 84a490f661..05cb798732 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -273,7 +273,7 @@ void LLWindowListener::keyDown(LLSD const & evt) else { response.error(STRINGIZE(evt["op"].asString() << " request " - "element specified byt \"path\": '" << path << "'" + "element specified by \"path\": '" << path << "'" << " is not visible")); } } @@ -421,7 +421,7 @@ static void mouseEvent(const MouseFunc& func, const LLSD& request) response.warn(STRINGIZE(request["op"].asString() << " request " "specified \"path\" = '" << path << "', but frontmost LLView at (" << pos.mX << ", " << pos.mY - << ") is '" << frontmost->getPathname() << "'")); + << ") is '" << LLView::getPathname(frontmost) << "'")); } // Instantiate a TemporaryDrilldownFunc to route incoming mouse events -- cgit v1.2.3 From 54399f1f87af40633035df9ec1cbadf139844621 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 1 Sep 2011 13:01:08 -0400 Subject: CHOP-763: publish LLControlGroup::typeStringToEnum(), typeEnumToString() These LLControlGroup methods were marked 'protected'. But they're important for introspection: LLControlVariable::type() returns an eControlType; understanding that value outside a C++ context requires typeEnumToString(). --- indra/llxml/llcontrol.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h index e402061e1f..31eb59c16e 100644 --- a/indra/llxml/llcontrol.h +++ b/indra/llxml/llcontrol.h @@ -185,9 +185,10 @@ protected: ctrl_name_table_t mNameTable; std::string mTypeString[TYPE_COUNT]; +public: eControlType typeStringToEnum(const std::string& typestr); std::string typeEnumToString(eControlType typeenum); -public: + LLControlGroup(const std::string& name); ~LLControlGroup(); void cleanup(); -- cgit v1.2.3 From 3ddf3aef9b2f2bb85932bd33b9daac5e59d3018a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 1 Sep 2011 13:12:23 -0400 Subject: CHOP-763: Promote Response class from llwindowlistener.cpp to LLEventAPI. This is a generally-useful idiom, extending the sendReply() convenience function -- it shouldn't remain buried in a single .cpp file. --- indra/llcommon/lleventapi.cpp | 30 +++++++++++++++ indra/llcommon/lleventapi.h | 78 ++++++++++++++++++++++++++++++++++++++ indra/newview/llwindowlistener.cpp | 43 +-------------------- 3 files changed, 110 insertions(+), 41 deletions(-) (limited to 'indra') diff --git a/indra/llcommon/lleventapi.cpp b/indra/llcommon/lleventapi.cpp index 4270c8b511..ff5459c1eb 100644 --- a/indra/llcommon/lleventapi.cpp +++ b/indra/llcommon/lleventapi.cpp @@ -34,6 +34,7 @@ // std headers // external library headers // other Linden headers +#include "llerror.h" LLEventAPI::LLEventAPI(const std::string& name, const std::string& desc, const std::string& field): lbase(name, field), @@ -45,3 +46,32 @@ LLEventAPI::LLEventAPI(const std::string& name, const std::string& desc, const s LLEventAPI::~LLEventAPI() { } + +LLEventAPI::Response::Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey): + mResp(seed), + mReq(request), + mKey(replyKey) +{} + +LLEventAPI::Response::~Response() +{ + // When you instantiate a stack Response object, if the original + // request requested a reply, send it when we leave this block, no + // matter how. + sendReply(mResp, mReq, mKey); +} + +void LLEventAPI::Response::warn(const std::string& warning) +{ + LL_WARNS("LLEventAPI::Response") << warning << LL_ENDL; + mResp["warnings"].append(warning); +} + +void LLEventAPI::Response::error(const std::string& error) +{ + // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut + // down altogether. + LL_WARNS("LLEventAPI::Response") << error << LL_ENDL; + + mResp["error"] = error; +} diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index d75d521e8e..332dee9550 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -76,6 +76,84 @@ public: LLEventDispatcher::add(name, desc, callable, required); } + /** + * Instantiate a Response object in any LLEventAPI subclass method that + * wants to guarantee a reply (if requested) will be sent on exit from the + * method. The reply will be sent if request.has(@a replyKey), default + * "reply". If specified, the value of request[replyKey] is the name of + * the LLEventPump on which to send the reply. Conventionally you might + * code something like: + * + * @code + * void MyEventAPI::someMethod(const LLSD& request) + * { + * // Send a reply event as long as request.has("reply") + * Response response(LLSD(), request); + * // ... + * // will be sent in reply event + * response["somekey"] = some_data; + * } + * @endcode + */ + class Response + { + public: + /** + * Instantiating a Response object in an LLEventAPI subclass method + * ensures that, if desired, a reply event will be sent. + * + * @a seed is the initial reply LLSD that will be further decorated before + * being sent as the reply + * + * @a request is the incoming request LLSD; we particularly care about + * [replyKey] and ["reqid"] + * + * @a replyKey [default "reply"] is the string name of the LLEventPump + * on which the caller wants a reply. If (! + * request.has(replyKey)), no reply will be sent. + */ + Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey="reply"); + ~Response(); + + /** + * @code + * if (some condition) + * { + * response.warn("warnings are logged and collected in [\"warnings\"]"); + * } + * @endcode + */ + void warn(const std::string& warning); + /** + * @code + * if (some condition isn't met) + * { + * // In a function returning void, you can validly 'return + * // expression' if the expression is itself of type void. But + * // returning is up to you; response.error() has no effect on + * // flow of control. + * return response.error("error message, logged and also sent as [\"error\"]"); + * } + * @endcode + */ + void error(const std::string& error); + + /** + * set other keys... + * + * @code + * // set any attributes you want to be sent in the reply + * response["info"] = some_value; + * // ... + * response["ok"] = went_well; + * @endcode + */ + LLSD& operator[](const LLSD::String& key) { return mResp[key]; } + + LLSD mResp, mReq; + LLSD::String mKey; + }; + private: std::string mDesc; }; diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 05cb798732..3e3287032c 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -134,46 +134,7 @@ protected: namespace { -class Response -{ -public: - Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey="reply"): - mResp(seed), - mReq(request), - mKey(replyKey) - {} - - ~Response() - { - // When you instantiate a stack Response object, if the original - // request requested a reply, send it when we leave this block, no - // matter how. - sendReply(mResp, mReq, mKey); - } - - void warn(const std::string& warning) - { - LL_WARNS("LLWindowListener") << warning << LL_ENDL; - mResp["warnings"].append(warning); - } - - void error(const std::string& error) - { - // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut - // down altogether. - LL_WARNS("LLWindowListener") << error << LL_ENDL; - - mResp["error"] = error; - } - - // set other keys... - LLSD& operator[](const LLSD::String& key) { return mResp[key]; } - - LLSD mResp, mReq; - LLSD::String mKey; -}; - -void insertViewInformation(Response & response, LLView * target) +void insertViewInformation(LLEventAPI::Response & response, LLView * target) { // Get info about this LLView* for when we send response. response["path"] = target->getPathname(); @@ -346,7 +307,7 @@ typedef boost::function MouseFunc; static void mouseEvent(const MouseFunc& func, const LLSD& request) { // Ensure we send response - Response response(LLSD(), request); + LLEventAPI::Response response(LLSD(), request); // We haven't yet established whether the incoming request has "x" and "y", // but capture this anyway, with 0 for omitted values. LLCoordGL pos(request["x"].asInteger(), request["y"].asInteger()); -- cgit v1.2.3 From 7215d1a9a9e6220d8744b662ab96feb41fc66ec8 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 1 Sep 2011 14:05:37 -0400 Subject: CHOP-763: Extend LLEventAPI "LLViewerControl" API; add queries. This is a significant refactoring of planned (but as yet unimplemented) work, though in fact it's almost completely compatible with the only implemented operation. The set() operation now requires op="set", where before that was inferred because set() was the only possibility. Whereas before LLViewerControlListener dispatched to different bound methods on the "group" key, with four known "group" string values, it now dispatches on the "op" key, supporting "set", "toggle", "get", "groups", "vars" -- the last two exposing query functionality. LLControlGroup is actually derived from LLInstanceTracker, keyed on string names, so we can look up instances using LLControlGroup::getInstance(const std::string&), or enumerate all such names. LLControlGroup similarly permits iterating over all defined LLControlVariables. The static LLViewerControlListener instance has been wrapped in an unnamed namespace and removed from llviewercontrollistener.h. The availability of the API depends on LLEventPumps::obtain(), rather than normal C++ visibility. --- indra/newview/llviewercontrollistener.cpp | 231 +++++++++++++++++++++--------- indra/newview/llviewercontrollistener.h | 10 +- 2 files changed, 169 insertions(+), 72 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewercontrollistener.cpp b/indra/newview/llviewercontrollistener.cpp index 8bc25fa281..361b96221c 100644 --- a/indra/newview/llviewercontrollistener.cpp +++ b/indra/newview/llviewercontrollistener.cpp @@ -31,99 +31,196 @@ #include "llviewercontrollistener.h" #include "llviewercontrol.h" +#include "llcontrol.h" +#include "llerror.h" +#include "llsdutil.h" +#include "stringize.h" +#include -LLViewerControlListener gSavedSettingsListener; +namespace { + +LLViewerControlListener sSavedSettingsListener; + +} // unnamed namespace LLViewerControlListener::LLViewerControlListener() : LLEventAPI("LLViewerControl", - "LLViewerControl listener: set, toggle or set default for various controls", - "group") + "LLViewerControl listener: set, toggle or set default for various controls") { - add("Global", - "Set gSavedSettings control [\"key\"] to value [\"value\"]", - boost::bind(&LLViewerControlListener::set, &gSavedSettings, _1)); - add("PerAccount", - "Set gSavedPerAccountSettings control [\"key\"] to value [\"value\"]", - boost::bind(&LLViewerControlListener::set, &gSavedPerAccountSettings, _1)); - add("Warning", - "Set gWarningSettings control [\"key\"] to value [\"value\"]", - boost::bind(&LLViewerControlListener::set, &gWarningSettings, _1)); - add("Crash", - "Set gCrashSettings control [\"key\"] to value [\"value\"]", - boost::bind(&LLViewerControlListener::set, &gCrashSettings, _1)); - -#if 0 - add(/*"toggleControl",*/ "Global", boost::bind(&LLViewerControlListener::toggleControl, &gSavedSettings, _1)); - add(/*"toggleControl",*/ "PerAccount", boost::bind(&LLViewerControlListener::toggleControl, &gSavedPerAccountSettings, _1)); - add(/*"toggleControl",*/ "Warning", boost::bind(&LLViewerControlListener::toggleControl, &gWarningSettings, _1)); - add(/*"toggleControl",*/ "Crash", boost::bind(&LLViewerControlListener::toggleControl, &gCrashSettings, _1)); - - add(/*"setDefault",*/ "Global", boost::bind(&LLViewerControlListener::setDefault, &gSavedSettings, _1)); - add(/*"setDefault",*/ "PerAccount", boost::bind(&LLViewerControlListener::setDefault, &gSavedPerAccountSettings, _1)); - add(/*"setDefault",*/ "Warning", boost::bind(&LLViewerControlListener::setDefault, &gWarningSettings, _1)); - add(/*"setDefault",*/ "Crash", boost::bind(&LLViewerControlListener::setDefault, &gCrashSettings, _1)); -#endif // 0 + std::ostringstream groupnames; + groupnames << "[\"group\"] is one of "; + const char* delim = ""; + for (LLControlGroup::key_iter cgki(LLControlGroup::beginKeys()), + cgkend(LLControlGroup::endKeys()); + cgki != cgkend; ++cgki) + { + groupnames << delim << '"' << *cgki << '"'; + delim = ", "; + } + groupnames << '\n'; + std::string grouphelp(groupnames.str()); + std::string replyhelp("If [\"reply\"] requested, send new [\"value\"] on specified LLEventPump\n"); + + add("set", + std::string("Set [\"group\"] control [\"key\"] to optional value [\"value\"]\n" + "If [\"value\"] omitted, set to control's defined default value\n") + + grouphelp + replyhelp, + &LLViewerControlListener::set, + LLSDMap("group", LLSD())("key", LLSD())); + add("toggle", + std::string("Toggle [\"group\"] control [\"key\"], if boolean\n") + grouphelp + replyhelp, + &LLViewerControlListener::toggle, + LLSDMap("group", LLSD())("key", LLSD())); + add("get", + std::string("Query [\"group\"] control [\"key\"], replying on LLEventPump [\"reply\"]\n") + + grouphelp, + &LLViewerControlListener::get, + LLSDMap("group", LLSD())("key", LLSD())("reply", LLSD())); + add("groups", + "Send on LLEventPump [\"reply\"] an array [\"groups\"] of valid group names", + &LLViewerControlListener::groups, + LLSDMap("reply", LLSD())); + add("vars", + std::string("For [\"group\"], send on LLEventPump [\"reply\"] an array [\"vars\"],\n" + "each of whose entries looks like:\n" + " [\"name\"], [\"type\"], [\"value\"], [\"comment\"]\n") + grouphelp, + &LLViewerControlListener::vars, + LLSDMap("group", LLSD())("reply", LLSD())); } -//static -void LLViewerControlListener::set(LLControlGroup * controls, LLSD const & event_data) +struct Info { - if(event_data.has("key")) + Info(const LLSD& request): + response(LLSD(), request), + groupname(request["group"]), + group(LLControlGroup::getInstance(groupname)), + key(request["key"]), + control(NULL) { - std::string key(event_data["key"]); + if (! group) + { + response.error(STRINGIZE("Unrecognized group '" << groupname << "'")); + return; + } - if(controls->controlExists(key)) + control = group->getControl(key); + if (! control) { - controls->setUntypedValue(key, event_data["value"]); + response.error(STRINGIZE("In group '" << groupname + << "', unrecognized control key '" << key << "'")); } - else + } + + ~Info() + { + // If in fact the request passed to our constructor names a valid + // group and key, grab the final value of the indicated control and + // stuff it in our response. Since this outer destructor runs before + // the contained Response destructor, this data will go into the + // response we send. + if (control) { - llwarns << "requested unknown control: \"" << key << '\"' << llendl; + response["name"] = control->getName(); + response["type"] = group->typeEnumToString(control->type()); + response["value"] = control->get(); + response["comment"] = control->getComment(); } } + + LLEventAPI::Response response; + std::string groupname; + LLControlGroup* group; + std::string key; + LLControlVariable* control; +}; + +//static +void LLViewerControlListener::set(LLSD const & request) +{ + Info info(request); + if (! info.control) + return; + + if (request.has("value")) + { + info.control->setValue(request["value"]); + } + else + { + info.control->resetToDefault(); + } } //static -void LLViewerControlListener::toggleControl(LLControlGroup * controls, LLSD const & event_data) +void LLViewerControlListener::toggle(LLSD const & request) { - if(event_data.has("key")) + Info info(request); + if (! info.control) + return; + + if (info.control->isType(TYPE_BOOLEAN)) + { + info.control->set(! info.control->get().asBoolean()); + } + else { - std::string key(event_data["key"]); + info.response.error(STRINGIZE("toggle of non-boolean '" << info.groupname + << "' control '" << info.key + << "', type is " + << info.group->typeEnumToString(info.control->type()))); + } +} - if(controls->controlExists(key)) - { - LLControlVariable * control = controls->getControl(key); - if(control->isType(TYPE_BOOLEAN)) - { - control->set(!control->get().asBoolean()); - } - else - { - llwarns << "requested toggle of non-boolean control: \"" << key << "\", type is " << control->type() << llendl; - } - } - else - { - llwarns << "requested unknown control: \"" << key << '\"' << llendl; - } +void LLViewerControlListener::get(LLSD const & request) +{ + // The Info constructor and destructor actually do all the work here. + Info info(request); +} + +void LLViewerControlListener::groups(LLSD const & request) +{ + // No Info, we're not looking up either a group or a control name. + Response response(LLSD(), request); + for (LLControlGroup::key_iter cgki(LLControlGroup::beginKeys()), + cgkend(LLControlGroup::endKeys()); + cgki != cgkend; ++cgki) + { + response["groups"].append(*cgki); } } -//static -void LLViewerControlListener::setDefault(LLControlGroup * controls, LLSD const & event_data) +struct CollectVars: public LLControlGroup::ApplyFunctor { - if(event_data.has("key")) + CollectVars(LLControlGroup* g): + mGroup(g) + {} + + virtual void apply(const std::string& name, LLControlVariable* control) { - std::string key(event_data["key"]); + vars.append(LLSDMap + ("name", name) + ("type", mGroup->typeEnumToString(control->type())) + ("value", control->get()) + ("comment", control->getComment())); + } - if(controls->controlExists(key)) - { - LLControlVariable * control = controls->getControl(key); - control->resetToDefault(); - } - else - { - llwarns << "requested unknown control: \"" << key << '\"' << llendl; - } + LLControlGroup* mGroup; + LLSD vars; +}; + +void LLViewerControlListener::vars(LLSD const & request) +{ + // This method doesn't use Info, because we're not looking up a specific + // control name. + Response response(LLSD(), request); + std::string groupname(request["group"]); + LLControlGroup* group(LLControlGroup::getInstance(groupname)); + if (! group) + { + return response.error(STRINGIZE("Unrecognized group '" << groupname << "'")); } + + CollectVars collector(group); + group->applyToAll(&collector); + response["vars"] = collector.vars; } diff --git a/indra/newview/llviewercontrollistener.h b/indra/newview/llviewercontrollistener.h index fd211b97af..2e72046924 100644 --- a/indra/newview/llviewercontrollistener.h +++ b/indra/newview/llviewercontrollistener.h @@ -40,11 +40,11 @@ public: LLViewerControlListener(); private: - static void set(LLControlGroup *controls, LLSD const & event_data); - static void toggleControl(LLControlGroup *controls, LLSD const & event_data); - static void setDefault(LLControlGroup *controls, LLSD const & event_data); + static void set(LLSD const & event_data); + static void toggle(LLSD const & event_data); + static void get(LLSD const & event_data); + static void groups(LLSD const & event_data); + static void vars(LLSD const & event_data); }; -extern LLViewerControlListener gSavedSettingsListener; - #endif // LL_LLVIEWERCONTROLLISTENER_H -- cgit v1.2.3 From 654cd3f89786e5c19cf26472ccf5a402a22ea661 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sun, 4 Sep 2011 07:08:23 -0400 Subject: CHOP-763: Make LLView::TemporaryDrilldownFunc boost::noncopyable. Code review with Alain turned up the fact that TemporaryDrilldownFunc, simple to the point of naivety, doesn't address the case of its being copied. Making it boost::noncopyable should turn any such usage into a compile error. --- indra/llui/llview.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 97151c4fb4..fcae75c447 100644 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -51,6 +51,7 @@ #include #include +#include class LLSD; @@ -614,7 +615,7 @@ public: // LLView::TemporaryDrilldownFunc scoped_func(myfunctor); // // ... test with myfunctor ... // } // exiting block restores original LLView::sDrilldown - class TemporaryDrilldownFunc + class TemporaryDrilldownFunc: public boost::noncopyable { public: TemporaryDrilldownFunc(const DrilldownFunc& func): -- cgit v1.2.3 From ecba41419f6470cc3d85bbb277ef88ebbf266feb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 6 Sep 2011 13:25:27 -0400 Subject: CHOP-763: Nested LLEventAPI::Response class needs LL_COMMON_API too. Apparently the outer class's LL_COMMON_API marker affects all outer class members, but not nested classes. Making it explicit fixes Windows link errors. --- indra/llcommon/lleventapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra') diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h index 332dee9550..64d038ade4 100644 --- a/indra/llcommon/lleventapi.h +++ b/indra/llcommon/lleventapi.h @@ -95,7 +95,7 @@ public: * } * @endcode */ - class Response + class LL_COMMON_API Response { public: /** -- cgit v1.2.3