X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/850ff4855026066770d80c376ee6fc864169509c..9000c6246f539bcffcf2bb6432ef37f9f6df7ac8:/src/gtk1/window.cpp diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 83092d0e09..ccdd0eb927 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -36,15 +36,19 @@ #include "wx/settings.h" #include "wx/log.h" +#ifdef __WXDEBUG__ + #include "wx/thread.h" +#endif + #include -#include "gdk/gdk.h" -#include "gtk/gtk.h" -#include "gdk/gdkprivate.h" -#include "gdk/gdkkeysyms.h" -#include "wx/gtk/win_gtk.h" +#include +#include +#include +#include +#include -#include "gdk/gdkx.h" +#include //----------------------------------------------------------------------------- // documentation on internals @@ -198,12 +202,20 @@ static int g_sendActivateEvent = -1; the last click here */ static guint32 gs_timeLastClick = 0; +extern bool g_mainThreadLocked; + //----------------------------------------------------------------------------- // debug //----------------------------------------------------------------------------- #ifdef __WXDEBUG__ +#if wxUSE_THREADS +# define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance"); +#else +# define DEBUG_MAIN_THREAD +#endif + static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), const wxChar *WXUNUSED(name) ) @@ -240,6 +252,8 @@ void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window } } +#else +#define DEBUG_MAIN_THREAD #endif // Debug //----------------------------------------------------------------------------- @@ -289,27 +303,33 @@ static void draw_frame( GtkWidget *widget, wxWindow *win ) if (win->HasScrolling()) { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget); - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget)->klass ); - -/* - GtkWidget *hscrollbar = scroll_window->hscrollbar; - GtkWidget *vscrollbar = scroll_window->vscrollbar; + GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget); + + GtkRequisition vscroll_req; + vscroll_req.width = 2; + vscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->vscrollbar)->klass )->size_request ) + (scroll_window->vscrollbar, &vscroll_req ); + + GtkRequisition hscroll_req; + hscroll_req.width = 2; + hscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->hscrollbar)->klass )->size_request ) + (scroll_window->hscrollbar, &hscroll_req ); + + GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget)->klass ); - we use this instead: range.slider_width = 11 + 2*2pts edge -*/ - - if (scroll_window->vscrollbar_visible) - { - dw += 15; /* dw += vscrollbar->allocation.width; */ - dw += scroll_class->scrollbar_spacing; - } + if (scroll_window->vscrollbar_visible) + { + dw += vscroll_req.width; + dw += scroll_class->scrollbar_spacing; + } - if (scroll_window->hscrollbar_visible) - { - dh += 15; /* dh += hscrollbar->allocation.height; */ - dh += scroll_class->scrollbar_spacing; - } + if (scroll_window->hscrollbar_visible) + { + dh += hscroll_req.height; + dh += scroll_class->scrollbar_spacing; + } } int dx = 0; @@ -590,6 +610,8 @@ static long map_to_wx_keysym( KeySym keysym ) static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (!win->m_hasVMT) return; @@ -629,6 +651,8 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -665,6 +689,8 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -817,6 +843,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -873,6 +901,8 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1037,6 +1067,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1155,6 +1187,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1275,6 +1309,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1335,6 +1371,8 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED( static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1378,6 +1416,8 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1424,6 +1464,8 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1470,6 +1512,8 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1504,6 +1548,8 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win ) static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1537,6 +1583,8 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win ) static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1557,6 +1605,8 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1579,6 +1629,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -1600,6 +1652,8 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget), GdkEventButton *WXUNUSED(gdk_event), wxWindow *win ) { + DEBUG_MAIN_THREAD + // don't test here as we can release the mouse while being over // a different window than the slider @@ -1631,6 +1685,8 @@ wxWindow *wxWindowBase::FindFocus() static gint gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win ) { + DEBUG_MAIN_THREAD + if (g_isIdle) wxapp_install_idle_handler(); @@ -2361,24 +2417,6 @@ void wxWindow::DoSetClientSize( int width, int height ) int dw = 0; int dh = 0; -#if (GTK_MINOR_VERSION == 0) - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) - { - if (HasScrolling()) - { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); -#if 0 // unused - if this is ok, just remove this line (VZ) - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); -#endif // 0 - - GtkWidget *viewport = scroll_window->viewport; - GtkStyleClass *viewport_class = viewport->style->klass; - - dw += 2 * viewport_class->xthickness; - dh += 2 * viewport_class->ythickness; - } - } -#else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { /* when using GTK 1.2 we set the shadow border size to 2 */ @@ -2391,32 +2429,37 @@ void wxWindow::DoSetClientSize( int width, int height ) dw += 1 * 2; dh += 1 * 2; } -#endif if (HasScrolling()) { -/* - GtkWidget *hscrollbar = scroll_window->hscrollbar; - GtkWidget *vscrollbar = scroll_window->vscrollbar; - - we use this instead: range.slider_width = 11 + 2*2pts edge -*/ - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); + + GtkRequisition vscroll_req; + vscroll_req.width = 2; + vscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->vscrollbar)->klass )->size_request ) + (scroll_window->vscrollbar, &vscroll_req ); + + GtkRequisition hscroll_req; + hscroll_req.width = 2; + hscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->hscrollbar)->klass )->size_request ) + (scroll_window->hscrollbar, &hscroll_req ); + GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); if (scroll_window->vscrollbar_visible) { - dw += 15; /* dw += vscrollbar->allocation.width; */ + dw += vscroll_req.width; dw += scroll_class->scrollbar_spacing; } if (scroll_window->hscrollbar_visible) { - dh += 15; /* dh += hscrollbar->allocation.height; */ + dh += hscroll_req.height; dh += scroll_class->scrollbar_spacing; } - } + } SetSize( width+dw, height+dh ); } @@ -2436,24 +2479,6 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const int dw = 0; int dh = 0; -#if (GTK_MINOR_VERSION == 0) - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) - { - if (HasScrolling()) - { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); -#if 0 // unused - if this is ok, just remove this line (VZ) - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); -#endif // 0 - - GtkWidget *viewport = scroll_window->viewport; - GtkStyleClass *viewport_class = viewport->style->klass; - - dw += 2 * viewport_class->xthickness; - dh += 2 * viewport_class->ythickness; - } - } -#else if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) { /* when using GTK 1.2 we set the shadow border size to 2 */ @@ -2466,28 +2491,34 @@ void wxWindow::DoGetClientSize( int *width, int *height ) const dw += 1 * 2; dh += 1 * 2; } -#endif + if (HasScrolling()) { -/* - GtkWidget *hscrollbar = scroll_window->hscrollbar; - GtkWidget *vscrollbar = scroll_window->vscrollbar; - - we use this instead: range.slider_width = 11 + 2*2pts edge -*/ - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); + + GtkRequisition vscroll_req; + vscroll_req.width = 2; + vscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->vscrollbar)->klass )->size_request ) + (scroll_window->vscrollbar, &vscroll_req ); + + GtkRequisition hscroll_req; + hscroll_req.width = 2; + hscroll_req.height = 2; + (* GTK_WIDGET_CLASS( GTK_OBJECT(scroll_window->hscrollbar)->klass )->size_request ) + (scroll_window->hscrollbar, &hscroll_req ); + GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); if (scroll_window->vscrollbar_visible) { - dw += 15; /* dw += vscrollbar->allocation.width; */ + dw += vscroll_req.width; dw += scroll_class->scrollbar_spacing; } if (scroll_window->hscrollbar_visible) { - dh += 15; /* dh += hscrollbar->allocation.height; */ + dh += hscroll_req.height; dh += scroll_class->scrollbar_spacing; } } @@ -2939,7 +2970,7 @@ bool wxWindow::SetForegroundColour( const wxColour &colour ) GtkStyle *wxWindow::GetWidgetStyle() { - if (m_widgetStyle) gtk_style_unref( m_widgetStyle ); + if (m_widgetStyle) return m_widgetStyle; GtkStyle *def = gtk_rc_get_style( m_widget ); @@ -2947,7 +2978,6 @@ GtkStyle *wxWindow::GetWidgetStyle() def = gtk_widget_get_default_style(); m_widgetStyle = gtk_style_copy( def ); - m_widgetStyle->engine_data = def->engine_data; m_widgetStyle->klass = def->klass; return m_widgetStyle;