nsIWidget::CaptureMouse works almost

This commit is contained in:
pavlov%netscape.com 1999-09-10 23:09:32 +00:00
parent 8d83096153
commit cc1faf8d2f
3 changed files with 14 additions and 49 deletions

View File

@ -318,34 +318,6 @@ NS_IMETHODIMP nsWidget::SetModal(void)
return NS_OK;
}
//-------------------------------------------------------------------------
//
// grab mouse events for this widget
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::CaptureMouse(PRBool aCapture)
{
if (aCapture)
{
mGrabTime = gdk_time_get();
gdk_pointer_grab (mWidget->window, PR_TRUE,(GdkEventMask)
(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_POINTER_MOTION_MASK),
mWidget->window, NULL, GDK_CURRENT_TIME);
// gtk_grab_add(mWidget);
}
else
{
gdk_pointer_ungrab(mGrabTime);
// gtk_grab_remove(mWidget);
}
return NS_OK;
}
NS_IMETHODIMP nsWidget::IsVisible(PRBool &aState)
{
if (mWidget)
@ -1634,6 +1606,10 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
nsMouseEvent event;
PRUint32 eventType = 0;
#ifdef DEBUG_pavlov
printf("button press\n");
#endif
// Switch on single, double, triple click.
switch (aGdkButtonEvent->type)
{

View File

@ -85,7 +85,6 @@ public:
NS_IMETHOD SetModal(void);
NS_IMETHOD Show(PRBool state);
NS_IMETHOD IsVisible(PRBool &aState);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
@ -123,10 +122,12 @@ public:
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
// the following are nsWindow specific, and just stubbed here
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) { return NS_ERROR_FAILURE; }
NS_IMETHOD SetMenuBar(nsIMenuBar *aMenuBar) { return NS_ERROR_FAILURE; }
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; }
// *could* be done on a widget, but that would be silly wouldn't it?
NS_IMETHOD CaptureMouse(PRBool aCapture) { return NS_ERROR_FAILURE; }
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);

View File

@ -91,9 +91,6 @@ NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
gint x;
gint y;
#ifdef DEBUG_pavlov
g_print("nsWindow::WidgetToScreen\n");
#endif
if (mIsToplevel && mShell)
{
if (mShell->window)
@ -101,9 +98,6 @@ NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
gdk_window_get_origin(mWidget->window, &x, &y);
aNewRect.x = x + aOldRect.x;
aNewRect.y = y + aOldRect.y;
#ifdef DEBUG_pavlov
g_print(" x = %i, y = %i\n", x, y);
#endif
}
else
return NS_ERROR_FAILURE;
@ -115,9 +109,6 @@ NS_IMETHODIMP nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
gdk_window_get_origin(mWidget->window, &x, &y);
aNewRect.x = x + aOldRect.x;
aNewRect.y = y + aOldRect.y;
#ifdef DEBUG_pavlov
g_print(" x = %i, y = %i\n", x, y);
#endif
}
else
return NS_ERROR_FAILURE;
@ -553,7 +544,6 @@ NS_IMETHODIMP nsWindow::Show(PRBool bState)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWindow::CaptureMouse(PRBool aCapture)
{
#ifdef DEBUG_pavlov
GtkWidget *grabWidget;
if (mIsToplevel && mShell)
@ -563,27 +553,25 @@ NS_IMETHODIMP nsWindow::CaptureMouse(PRBool aCapture)
if (aCapture)
{
printf("grabbing mShell\n");
printf("grabbing widget\n");
mGrabTime = gdk_time_get();
gdk_pointer_grab (GDK_ROOT_WINDOW(), PR_TRUE,(GdkEventMask)
GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
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 |
GDK_POINTER_MOTION_MASK),
(GdkWindow*) NULL, (GdkCursor*) NULL, mGrabTime);
(GdkWindow*) NULL, cursor, GDK_CURRENT_TIME);
gdk_cursor_destroy(cursor);
gtk_grab_add(grabWidget);
}
else
{
printf("ungrabbing mShell\n");
gdk_pointer_ungrab(mGrabTime);
printf("ungrabbing widget\n");
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(grabWidget);
}
return NS_OK;
#else
return NS_ERROR_FAILURE;
#endif
}