From 6987a6c3d060a29c1182f9836c8c641ff7c1d72a Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 7 Sep 1998 22:38:10 +0000 Subject: [PATCH] I debug DialogEd for five hours and then Karsten tells me that CaptureMouse is broken. Doh. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@712 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 97 ++++++++++++++++----------------- src/gtk1/window.cpp | 97 ++++++++++++++++----------------- utils/dialoged/src/dlghndlr.cpp | 2 - 3 files changed, 96 insertions(+), 100 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 7cba0eb41e..eec08efb5b 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -116,7 +116,7 @@ extern wxList wxPendingDelete; extern wxList wxTopLevelWindows; extern bool g_blockEventsOnDrag; -wxWindow *g_captureWindow = (wxWindow*)NULL; + bool g_capturing = FALSE; //----------------------------------------------------------------------------- // "expose_event" (of m_wxwindow, not of m_widget) @@ -300,8 +300,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) @@ -374,21 +372,24 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -407,8 +408,6 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -443,21 +442,24 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -476,8 +478,6 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -504,21 +504,24 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -609,8 +612,6 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -635,8 +636,6 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -1998,7 +1997,7 @@ void wxWindow::CaptureMouse(void) GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), (GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME ); - g_captureWindow = this; + g_capturing = TRUE; } void wxWindow::ReleaseMouse(void) @@ -2006,7 +2005,7 @@ void wxWindow::ReleaseMouse(void) GtkWidget *connect_widget = GetConnectWidget(); gtk_grab_remove( connect_widget ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); - g_captureWindow = (wxWindow*) NULL;; + g_capturing = FALSE; } void wxWindow::SetTitle( const wxString &WXUNUSED(title) ) diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 7cba0eb41e..eec08efb5b 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -116,7 +116,7 @@ extern wxList wxPendingDelete; extern wxList wxTopLevelWindows; extern bool g_blockEventsOnDrag; -wxWindow *g_captureWindow = (wxWindow*)NULL; + bool g_capturing = FALSE; //----------------------------------------------------------------------------- // "expose_event" (of m_wxwindow, not of m_widget) @@ -300,8 +300,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (win->m_wxwindow) @@ -374,21 +372,24 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -407,8 +408,6 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -443,21 +442,24 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -476,8 +478,6 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion { if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -504,21 +504,24 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion // Some control don't have their own X window and thus cannot get // any events. - wxNode *node = win->GetChildren()->First(); - while (node) + if (!g_capturing) { - wxWindow *child = (wxWindow*)node->Data(); - if ((child->m_x <= event.m_x) && - (child->m_y <= event.m_y) && - (child->m_x+child->m_width >= event.m_x) && - (child->m_y+child->m_height >= event.m_y)) + wxNode *node = win->GetChildren()->First(); + while (node) { - win = child; - event.m_x -= child->m_x; - event.m_y -= child->m_y; - break; + wxWindow *child = (wxWindow*)node->Data(); + if ((child->m_x <= event.m_x) && + (child->m_y <= event.m_y) && + (child->m_x+child->m_width >= event.m_x) && + (child->m_y+child->m_height >= event.m_y)) + { + win = child; + event.m_x -= child->m_x; + event.m_y -= child->m_y; + break; + } + node = node->Next(); } - node = node->Next(); } event.SetEventObject( win ); @@ -609,8 +612,6 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -635,8 +636,6 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ { if (widget->window != gdk_event->window) return TRUE; - if ((g_captureWindow) && (win != g_captureWindow)) return TRUE; - if (g_blockEventsOnDrag) return TRUE; if (!win->HasVMT()) return TRUE; @@ -1998,7 +1997,7 @@ void wxWindow::CaptureMouse(void) GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK), (GdkWindow *) NULL, (GdkCursor *) NULL, GDK_CURRENT_TIME ); - g_captureWindow = this; + g_capturing = TRUE; } void wxWindow::ReleaseMouse(void) @@ -2006,7 +2005,7 @@ void wxWindow::ReleaseMouse(void) GtkWidget *connect_widget = GetConnectWidget(); gtk_grab_remove( connect_widget ); gdk_pointer_ungrab ( GDK_CURRENT_TIME ); - g_captureWindow = (wxWindow*) NULL;; + g_capturing = FALSE; } void wxWindow::SetTitle( const wxString &WXUNUSED(title) ) diff --git a/utils/dialoged/src/dlghndlr.cpp b/utils/dialoged/src/dlghndlr.cpp index f312fb0ec0..4c6b67b9da 100644 --- a/utils/dialoged/src/dlghndlr.cpp +++ b/utils/dialoged/src/dlghndlr.cpp @@ -379,8 +379,6 @@ void wxResourceEditorDialogHandler::ProcessItemEvent(wxControl *item, wxMouseEve { wxResourceEditorControlHandler *childHandler = (wxResourceEditorControlHandler *)item->GetEventHandler(); - if (dragItem) childHandler = (wxResourceEditorControlHandler *)dragItem->GetEventHandler(); - long x, y; event.Position(&x, &y); int keys = 0; -- 2.45.2