Adaptation of the CoolViewer patch that allows Linux users to paste by middle-clicking.

This commit is contained in:
Player Dagostino
2011-08-02 19:58:47 +02:00
parent 4b98d69c2f
commit 5009b0544e
9 changed files with 230 additions and 370 deletions

View File

@@ -601,47 +601,84 @@ bool LLViewerWindow::shouldShowToolTipFor(LLMouseHandler *mh)
return false;
}
BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask)
BOOL LLViewerWindow::handleAnyMouseClick(LLWindow *window, LLCoordGL pos, MASK mask, LLMouseHandler::EClickType clicktype, BOOL down)
{
std::string buttonname;
std::string buttonstatestr;
BOOL handled = FALSE;
S32 x = pos.mX;
S32 y = pos.mY;
x = llround((F32)x / mDisplayScale.mV[VX]);
y = llround((F32)y / mDisplayScale.mV[VY]);
LLView::sMouseHandlerMessage.clear();
if (down)
buttonstatestr = "down";
else
buttonstatestr = "up";
if (gDebugClicks)
switch (clicktype)
{
llinfos << "ViewerWindow left mouse down at " << x << "," << y << llendl;
case LLMouseHandler::CLICK_LEFT:
mLeftMouseDown = down;
buttonname = "Left";
break;
case LLMouseHandler::CLICK_RIGHT:
mRightMouseDown = down;
buttonname = "Right";
break;
case LLMouseHandler::CLICK_MIDDLE:
mMiddleMouseDown = down;
buttonname = "Middle";
break;
case LLMouseHandler::CLICK_DOUBLELEFT:
mLeftMouseDown = down;
buttonname = "Left Double Click";
break;
}
LLView::sMouseHandlerMessage.clear();
if (gMenuBarView)
{
// stop ALT-key access to menu
gMenuBarView->resetMenuTrigger();
}
mLeftMouseDown = TRUE;
if (gDebugClicks)
{
llinfos << "ViewerWindow " << buttonname << " mouse " << buttonstatestr << " at " << x << "," << y << llendl;
}
// Make sure we get a coresponding mouseup event, even if the mouse leaves the window
mWindow->captureMouse();
if (down)
{
mWindow->captureMouse();
}
else
{
mWindow->releaseMouse();
}
// Indicate mouse was active
gMouseIdleTimer.reset();
// Hide tooltips on mousedown
mToolTipBlocked = TRUE;
if (down)
{
mToolTipBlocked = TRUE;
mToolTip->setVisible(FALSE);
}
// Also hide hover info on mousedown
// Also hide hover info on mousedown/mouseup
if (gHoverView)
{
gHoverView->cancelHover();
}
// Don't let the user move the mouse out of the window until mouse up.
if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
if (LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown())
{
mWindow->setMouseClipping(TRUE);
mWindow->setMouseClipping(down);
}
LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
@@ -652,10 +689,9 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down handled by captor " << mouse_captor->getName() << llendl;
llinfos << buttonname << " Mouse " << buttonstatestr << " handled by captor " << mouse_captor->getName() << llendl;
}
return mouse_captor->handleMouseDown(local_x, local_y, mask);
return mouse_captor->handleAnyMouseClick(local_x, local_y, mask, clicktype, down);
}
// Topmost view gets a chance before the hierarchy
@@ -664,216 +700,94 @@ BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask
{
S32 local_x, local_y;
top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
if (top_ctrl->pointInView(local_x, local_y))
if (down)
{
return top_ctrl->handleMouseDown(local_x, local_y, mask);
}
if (top_ctrl->pointInView(local_x, local_y))
{
return top_ctrl->handleAnyMouseClick(local_x, local_y, mask, clicktype, down) ;
}
else
{
gFocusMgr.setTopCtrl(NULL);
}
}
else
{
gFocusMgr.setTopCtrl(NULL);
}
handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
}
// Give the UI views a chance to process the click
if( mRootView->handleMouseDown(x, y, mask) )
if( mRootView->handleAnyMouseClick(x, y, mask, clicktype, down) )
{
if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
llinfos << buttonname << " Mouse " << buttonstatestr << " " << LLView::sMouseHandlerMessage << llendl;
}
return TRUE;
}
else if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down not handled by view" << llendl;
llinfos << buttonname << " Mouse " << buttonstatestr << " not handled by view" << llendl;
}
// Do not allow tool manager to handle mouseclicks if we have disconnected
if (gDisconnected)
if (down)
{
return FALSE;
}
// Do not allow tool manager to handle mouseclicks if we have disconnected
if (gDisconnected)
{
return FALSE;
}
if(LLToolMgr::getInstance()->getCurrentTool()->handleMouseDown( x, y, mask ) )
if(LLToolMgr::getInstance()->getCurrentTool()->handleAnyMouseClick( x, y, mask, clicktype, down ) )
{
// This is necessary to force clicks in the world to cause edit
// boxes that might have keyboard focus to relinquish it, and hence
// cause a commit to update their value. JC
gFocusMgr.setKeyboardFocus(NULL);
return TRUE;
}
}
else
{
// This is necessary to force clicks in the world to cause edit
// boxes that might have keyboard focus to relinquish it, and hence
// cause a commit to update their value. JC
gFocusMgr.setKeyboardFocus(NULL);
return TRUE;
mWindow->releaseMouse();
LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
if( !handled )
{
handled = mRootView->handleAnyMouseClick(x, y, mask, clicktype, down);
}
if( !handled )
{
if (tool)
{
handled = tool->handleAnyMouseClick(x, y, mask, clicktype, down);
}
}
}
return FALSE;
return (!down);
}
BOOL LLViewerWindow::handleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask)
{
BOOL down = TRUE;
return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_LEFT,down);
}
BOOL LLViewerWindow::handleDoubleClick(LLWindow *window, LLCoordGL pos, MASK mask)
{
S32 x = pos.mX;
S32 y = pos.mY;
x = llround((F32)x / mDisplayScale.mV[VX]);
y = llround((F32)y / mDisplayScale.mV[VY]);
LLView::sMouseHandlerMessage.clear();
if (gDebugClicks)
{
llinfos << "ViewerWindow left mouse double-click at " << x << "," << y << llendl;
}
mLeftMouseDown = TRUE;
// Hide tooltips
if( mToolTip )
{
mToolTip->setVisible( FALSE );
}
LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
if( mouse_captor )
{
S32 local_x;
S32 local_y;
mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down handled by captor " << mouse_captor->getName() << llendl;
}
return mouse_captor->handleDoubleClick(local_x, local_y, mask);
}
// Check for hit on UI.
LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
if (top_ctrl)
{
S32 local_x, local_y;
top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
if (top_ctrl->pointInView(local_x, local_y))
{
return top_ctrl->handleDoubleClick(local_x, local_y, mask);
}
else
{
gFocusMgr.setTopCtrl(NULL);
}
}
if (mRootView->handleDoubleClick(x, y, mask))
{
if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down" << LLView::sMouseHandlerMessage << llendl;
}
return TRUE;
}
else if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Down not handled by view" << llendl;
}
// Why is this here? JC 9/3/2002
if (gNoRender)
{
return TRUE;
}
if(LLToolMgr::getInstance()->getCurrentTool()->handleDoubleClick( x, y, mask ) )
{
return TRUE;
}
// if we got this far and nothing handled a double click, pass a normal mouse down
return handleMouseDown(window, pos, mask);
// try handling as a double-click first, then a single-click if that
// wasn't handled.
BOOL down = TRUE;
return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_DOUBLELEFT,down) ||
handleMouseDown(window, pos, mask);
}
BOOL LLViewerWindow::handleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
{
S32 x = pos.mX;
S32 y = pos.mY;
x = llround((F32)x / mDisplayScale.mV[VX]);
y = llround((F32)y / mDisplayScale.mV[VY]);
LLView::sMouseHandlerMessage.clear();
if (gDebugClicks)
{
llinfos << "ViewerWindow left mouse up" << llendl;
}
mLeftMouseDown = FALSE;
// Indicate mouse was active
gMouseIdleTimer.reset();
// Hide tooltips on mouseup
if( mToolTip )
{
mToolTip->setVisible( FALSE );
}
// Also hide hover info on mouseup
if (gHoverView) gHoverView->cancelHover();
BOOL handled = FALSE;
mWindow->releaseMouse();
LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
if( tool->clipMouseWhenDown() )
{
mWindow->setMouseClipping(FALSE);
}
LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
if( mouse_captor )
{
S32 local_x;
S32 local_y;
mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
if (LLView::sDebugMouseHandling)
{
llinfos << "Left Mouse Up handled by captor " << mouse_captor->getName() << llendl;
}
return mouse_captor->handleMouseUp(local_x, local_y, mask);
}
LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
if (top_ctrl)
{
S32 local_x, local_y;
top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleMouseUp(local_x, local_y, mask);
}
if( !handled )
{
handled = mRootView->handleMouseUp(x, y, mask);
}
if (LLView::sDebugMouseHandling)
{
if (handled)
{
llinfos << "Left Mouse Up" << LLView::sMouseHandlerMessage << llendl;
}
else
{
llinfos << "Left Mouse Up not handled by view" << llendl;
}
}
if( !handled )
{
if (tool)
{
handled = tool->handleMouseUp(x, y, mask);
}
}
// Always handled as far as the OS is concerned.
return TRUE;
BOOL down = FALSE;
return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_LEFT,down);
}
@@ -886,89 +800,11 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
LLView::sMouseHandlerMessage.clear();
if (gDebugClicks)
{
llinfos << "ViewerWindow right mouse down at " << x << "," << y << llendl;
}
BOOL down = TRUE;
BOOL handle = handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down);
if (handle)
return handle;
if (gMenuBarView)
{
// stop ALT-key access to menu
gMenuBarView->resetMenuTrigger();
}
mRightMouseDown = TRUE;
// Make sure we get a coresponding mouseup event, even if the mouse leaves the window
mWindow->captureMouse();
// Hide tooltips
if( mToolTip )
{
mToolTip->setVisible( FALSE );
}
// Also hide hover info on mousedown
if (gHoverView)
{
gHoverView->cancelHover();
}
// Don't let the user move the mouse out of the window until mouse up.
if( LLToolMgr::getInstance()->getCurrentTool()->clipMouseWhenDown() )
{
mWindow->setMouseClipping(TRUE);
}
LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
if( mouse_captor )
{
S32 local_x;
S32 local_y;
mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
if (LLView::sDebugMouseHandling)
{
llinfos << "Right Mouse Down handled by captor " << mouse_captor->getName() << llendl;
}
return mouse_captor->handleRightMouseDown(local_x, local_y, mask);
}
LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
if (top_ctrl)
{
S32 local_x, local_y;
top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
if (top_ctrl->pointInView(local_x, local_y))
{
return top_ctrl->handleRightMouseDown(local_x, local_y, mask);
}
else
{
gFocusMgr.setTopCtrl(NULL);
}
}
if( mRootView->handleRightMouseDown(x, y, mask) )
{
if (LLView::sDebugMouseHandling)
{
llinfos << "Right Mouse Down" << LLView::sMouseHandlerMessage << llendl;
}
return TRUE;
}
else if (LLView::sDebugMouseHandling)
{
llinfos << "Right Mouse Down not handled by view" << llendl;
}
if(LLToolMgr::getInstance()->getCurrentTool()->handleRightMouseDown( x, y, mask ) )
{
// This is necessary to force clicks in the world to cause edit
// boxes that might have keyboard focus to relinquish it, and hence
// cause a commit to update their value. JC
gFocusMgr.setKeyboardFocus(NULL);
return TRUE;
}
// *HACK: this should be rolled into the composite tool logic, not
// hardcoded at the top level.
@@ -986,97 +822,15 @@ BOOL LLViewerWindow::handleRightMouseDown(LLWindow *window, LLCoordGL pos, MASK
BOOL LLViewerWindow::handleRightMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
{
S32 x = pos.mX;
S32 y = pos.mY;
x = llround((F32)x / mDisplayScale.mV[VX]);
y = llround((F32)y / mDisplayScale.mV[VY]);
LLView::sMouseHandlerMessage.clear();
// Don't care about caps lock for mouse events.
if (gDebugClicks)
{
llinfos << "ViewerWindow right mouse up" << llendl;
}
mRightMouseDown = FALSE;
// Indicate mouse was active
gMouseIdleTimer.reset();
// Hide tooltips on mouseup
if( mToolTip )
{
mToolTip->setVisible( FALSE );
}
// Also hide hover info on mouseup
if (gHoverView) gHoverView->cancelHover();
BOOL handled = FALSE;
mWindow->releaseMouse();
LLTool *tool = LLToolMgr::getInstance()->getCurrentTool();
if( tool->clipMouseWhenDown() )
{
mWindow->setMouseClipping(FALSE);
}
LLMouseHandler* mouse_captor = gFocusMgr.getMouseCapture();
if( mouse_captor )
{
S32 local_x;
S32 local_y;
mouse_captor->screenPointToLocal( x, y, &local_x, &local_y );
if (LLView::sDebugMouseHandling)
{
llinfos << "Right Mouse Up handled by captor " << mouse_captor->getName() << llendl;
}
return mouse_captor->handleRightMouseUp(local_x, local_y, mask);
}
LLUICtrl* top_ctrl = gFocusMgr.getTopCtrl();
if (top_ctrl)
{
S32 local_x, local_y;
top_ctrl->screenPointToLocal( x, y, &local_x, &local_y );
handled = top_ctrl->pointInView(local_x, local_y) && top_ctrl->handleRightMouseUp(local_x, local_y, mask);
}
if( !handled )
{
handled = mRootView->handleRightMouseUp(x, y, mask);
}
if (LLView::sDebugMouseHandling)
{
if (handled)
{
llinfos << "Right Mouse Up" << LLView::sMouseHandlerMessage << llendl;
}
else
{
llinfos << "Right Mouse Up not handled by view" << llendl;
}
}
if( !handled )
{
if (tool)
{
handled = tool->handleRightMouseUp(x, y, mask);
}
}
// Always handled as far as the OS is concerned.
return TRUE;
BOOL down = FALSE;
return handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_RIGHT,down);
}
BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MASK mask)
{
BOOL down = TRUE;
gVoiceClient->middleMouseState(true);
handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_MIDDLE,down);
// Always handled as far as the OS is concerned.
return TRUE;
@@ -1084,7 +838,9 @@ BOOL LLViewerWindow::handleMiddleMouseDown(LLWindow *window, LLCoordGL pos, MAS
BOOL LLViewerWindow::handleMiddleMouseUp(LLWindow *window, LLCoordGL pos, MASK mask)
{
BOOL down = FALSE;
gVoiceClient->middleMouseState(false);
handleAnyMouseClick(window,pos,mask,LLMouseHandler::CLICK_MIDDLE,down);
// Always handled as far as the OS is concerned.
return TRUE;
@@ -1463,6 +1219,7 @@ LLViewerWindow::LLViewerWindow(
mWindowRect(0, height, width, 0),
mVirtualWindowRect(0, height, width, 0),
mLeftMouseDown(FALSE),
mMiddleMouseDown(FALSE),
mRightMouseDown(FALSE),
mToolTip(NULL),
mToolTipBlocked(FALSE),