diff --git a/graf3d/gl/inc/TGLEventHandler.h b/graf3d/gl/inc/TGLEventHandler.h index f1f6d164f29561c937136f7a26dcfc9a8333c873..94898fbdbfd56fc8a2a8875c6ce51934f96ec0e3 100644 --- a/graf3d/gl/inc/TGLEventHandler.h +++ b/graf3d/gl/inc/TGLEventHandler.h @@ -53,6 +53,9 @@ protected: virtual Bool_t Rotate(Int_t xDelta, Int_t yDelta, Bool_t mod1, Bool_t mod2); + virtual void GrabMouse(); + virtual void UnGrabMouse(); + public: TGLEventHandler(TGWindow *w, TObject *obj); virtual ~TGLEventHandler(); diff --git a/graf3d/gl/src/TGLEventHandler.cxx b/graf3d/gl/src/TGLEventHandler.cxx index dbe683bb598203c6db29d3df3f37a714af6b7cd7..c48dac5d2015e3995a4b8611dfc0c66dd258f017 100644 --- a/graf3d/gl/src/TGLEventHandler.cxx +++ b/graf3d/gl/src/TGLEventHandler.cxx @@ -83,6 +83,32 @@ TGLEventHandler::~TGLEventHandler() delete fTooltip; } +//______________________________________________________________________________ +void TGLEventHandler::GrabMouse() +{ + // Acquire mouse grab. + + if (!fInPointerGrab) + { + gVirtualX->GrabPointer(fGLViewer->GetGLWidget()->GetId(), + kButtonPressMask | kButtonReleaseMask | kPointerMotionMask, + kNone, kNone, kTRUE, kFALSE); + fInPointerGrab = kTRUE; + } +} + +//______________________________________________________________________________ +void TGLEventHandler::UnGrabMouse() +{ + // Release mouse grab. + + if (fInPointerGrab) + { + gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); + fInPointerGrab = kFALSE; + } +} + //______________________________________________________________________________ void TGLEventHandler::ExecuteEvent(Int_t event, Int_t px, Int_t py) { @@ -354,13 +380,11 @@ Bool_t TGLEventHandler::HandleButton(Event_t * event) fActiveButtonID = event->fCode; } + // Button DOWN if (event->fType == kButtonPress) { - gVirtualX->GrabPointer(fGLViewer->GetGLWidget()->GetId(), - kButtonPressMask | kButtonReleaseMask | kPointerMotionMask, - kNone, kNone, kTRUE, kFALSE); - fInPointerGrab = kTRUE; + GrabMouse(); fGLViewer->MouseIdle(0, 0, 0); @@ -472,7 +496,11 @@ Bool_t TGLEventHandler::HandleButton(Event_t * event) gClient->GetDefaultRoot()->GetId(), event->fX, event->fY, x, y, childdum); const TGLPhysicalShape * selected = fGLViewer->fSelRec.GetPhysShape(); - if (selected) { + if (selected) + { + fActiveButtonID = 0; + UnGrabMouse(); + selected->InvokeContextMenu(*fGLViewer->fContextMenu, x, y); } // This is dangerous ... should have special menu. @@ -480,7 +508,9 @@ Bool_t TGLEventHandler::HandleButton(Event_t * event) // { // fGLViewer->fContextMenu->Popup(x, y, fGLViewer); // } - } else { + } + else + { fGLViewer->fDragAction = TGLViewer::kDragCameraDolly; } break; @@ -495,8 +525,7 @@ Bool_t TGLEventHandler::HandleButton(Event_t * event) if (fInPointerGrab) { - gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE); - fInPointerGrab = kFALSE; + UnGrabMouse(); } else { @@ -601,14 +630,14 @@ Bool_t TGLEventHandler::HandleDoubleClick(Event_t *event) return kFALSE; } + if (event->fCode > 3) + return kTRUE; + if (fActiveButtonID) return kTRUE; fActiveButtonID = event->fCode; - gVirtualX->GrabPointer(fGLViewer->GetGLWidget()->GetId(), - kButtonPressMask | kButtonReleaseMask | kPointerMotionMask, - kNone, kNone, kTRUE, kFALSE); - fInPointerGrab = kTRUE; + GrabMouse(); fGLViewer->MouseIdle(0, 0, 0); if (event->fCode == kButton1)