Fix bug #16766. This should fix the requirement to release the mouse before context menus work. r=pavlov, sr=blizzard. Patch from Kevin Buhr <buhr@stat.wisc.edu>. Thanks.

This commit is contained in:
blizzard%redhat.com 2001-02-07 04:16:20 +00:00
Родитель 7369375bea
Коммит fd8809073d
3 изменённых файлов: 16 добавлений и 24 удалений

Просмотреть файл

@ -118,18 +118,6 @@ void nsWidget::GetLastEventTime(guint32 *aTime)
*aTime = sLastEventTime;
}
void nsWidget::DragStarted(void)
{
if (sButtonMotionTarget)
{
sButtonMotionTarget = nsnull;
sButtonMotionRootX = -1;
sButtonMotionRootY = -1;
sButtonMotionWidgetX = -1;
sButtonMotionWidgetY = -1;
}
}
#ifdef USE_XIM
nsresult nsWidget::KillICSpotTimer ()
{
@ -409,7 +397,7 @@ NS_IMETHODIMP nsWidget::Destroy(void)
// we don't want people sending us events if we are the button motion target
if (sButtonMotionTarget == this)
sButtonMotionTarget = nsnull;
DropMotionTarget();
// ok, set our state
mIsDestroying = PR_TRUE;
@ -1757,7 +1745,7 @@ nsWidget::OnEnterNotifySignal(GdkEventCrossing * aGdkCrossingEvent)
//
// XXX ramiro - Same as above.
//
if (sButtonMotionTarget)
if (nsnull != sButtonMotionTarget)
{
return;
}
@ -2051,14 +2039,7 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent)
theWidget->DispatchMouseEvent(event);
NS_IF_RELEASE(theWidget);
if (sButtonMotionTarget)
{
sButtonMotionTarget = nsnull;
sButtonMotionRootX = -1;
sButtonMotionRootY = -1;
}
DropMotionTarget();
}
//////////////////////////////////////////////////////////////////////
/* virtual */ void

Просмотреть файл

@ -206,9 +206,11 @@ public:
static void SetLastEventTime(guint32 aTime);
static void GetLastEventTime(guint32 *aTime);
static void DropMotionTarget(void) { sButtonMotionTarget = nsnull; };
// inform the widget code that we are about to do a drag - it must
// release the sButtonMotionTarget if it is set.
static void DragStarted(void);
static void DragStarted(void) { DropMotionTarget(); };
protected:

Просмотреть файл

@ -821,6 +821,7 @@ void nsWindow::NativeGrab(PRBool aGrab)
if (aGrab) {
GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
DropMotionTarget();
gint retval;
retval = gdk_pointer_grab (GDK_SUPERWIN(mSuperWin)->bin_window, PR_TRUE,(GdkEventMask)
(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@ -853,6 +854,7 @@ void nsWindow::NativeGrab(PRBool aGrab)
printf("nsWindow::NativeGrab %p ungrab\n", this);
#endif
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
DropMotionTarget();
gdk_pointer_ungrab(GDK_CURRENT_TIME);
}
}
@ -2421,7 +2423,13 @@ NS_IMETHODIMP nsWindow::CaptureMouse(PRBool aCapture)
if (aCapture)
{
if (!grabWidget) {
g_print("nsWindow::CaptureMouse on NULL grabWidget\n");
return NS_ERROR_FAILURE;
}
GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
DropMotionTarget();
gdk_pointer_grab (GTK_WIDGET(grabWidget)->window, PR_TRUE,(GdkEventMask)
(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
@ -2432,8 +2440,9 @@ NS_IMETHODIMP nsWindow::CaptureMouse(PRBool aCapture)
}
else
{
DropMotionTarget();
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(grabWidget);
if (grabWidget) gtk_grab_remove(grabWidget);
}
return NS_OK;