X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/937013e0fd914d4c42f9f5ec98da665986b93dfa..872051d89bd098d1e6052fabc07174e67296a35f:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 5a6d9f2b49..7e637c83b0 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -33,10 +33,6 @@ #include "wx/fontutil.h" #include "wx/sysopt.h" -#ifdef __WXDEBUG__ - #include "wx/thread.h" -#endif - #include #include "wx/gtk/private.h" @@ -205,23 +201,10 @@ wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; GdkEvent *g_lastMouseEvent = (GdkEvent*) NULL; int g_lastButtonNumber = 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 -#else -#define DEBUG_MAIN_THREAD -#endif // Debug - // the trace mask used for the focus debugging messages #define TRACE_FOCUS _T("focus") @@ -275,35 +258,6 @@ wxWindow *wxFindFocusedChild(wxWindowGTK *win) return (wxWindow *)NULL; } -static void GetScrollbarWidth(GtkWidget* widget, int& w, int& h) -{ - GtkScrolledWindow* scroll_window = GTK_SCROLLED_WINDOW(widget); - GtkScrolledWindowClass* scroll_class = GTK_SCROLLED_WINDOW_CLASS(GTK_OBJECT_GET_CLASS(scroll_window)); - GtkRequisition scroll_req; - - w = 0; - if (scroll_window->vscrollbar_visible) - { - scroll_req.width = 2; - scroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request ) - (scroll_window->vscrollbar, &scroll_req ); - w = scroll_req.width + - scroll_class->scrollbar_spacing; - } - - h = 0; - if (scroll_window->hscrollbar_visible) - { - scroll_req.width = 2; - scroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request ) - (scroll_window->hscrollbar, &scroll_req ); - h = scroll_req.height + - scroll_class->scrollbar_spacing; - } -} - //----------------------------------------------------------------------------- // "size_request" of m_widget //----------------------------------------------------------------------------- @@ -336,8 +290,6 @@ gtk_window_expose_callback( GtkWidget*, GdkEventExpose *gdk_event, wxWindow *win ) { - DEBUG_MAIN_THREAD - #if 0 if (win->GetName()) { @@ -894,8 +846,6 @@ gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { - DEBUG_MAIN_THREAD - if (!win->m_hasVMT) return FALSE; if (g_blockEventsOnDrag) @@ -1108,8 +1058,6 @@ gtk_window_key_release_callback( GtkWidget * WXUNUSED(widget), GdkEventKey *gdk_event, wxWindowGTK *win ) { - DEBUG_MAIN_THREAD - if (!win->m_hasVMT) return FALSE; @@ -1277,8 +1225,6 @@ bool wxWindowGTK::GTKProcessEvent(wxEvent& event) const int wxWindowGTK::GTKCallbackCommonPrologue(GdkEventAny *event) const { - DEBUG_MAIN_THREAD - if (!m_hasVMT) return FALSE; if (g_blockEventsOnDrag) @@ -1633,8 +1579,6 @@ gtk_window_motion_notify_callback( GtkWidget * WXUNUSED(widget), static gboolean window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) { - DEBUG_MAIN_THREAD - if (gdk_event->direction != GDK_SCROLL_UP && gdk_event->direction != GDK_SCROLL_DOWN) { @@ -1643,6 +1587,8 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) wxMouseEvent event(wxEVT_MOUSEWHEEL); InitMouseEvent(win, event, gdk_event); + + // FIXME: Get these values from GTK or GDK event.m_linesPerAction = 3; event.m_wheelDelta = 120; if (gdk_event->direction == GDK_SCROLL_UP) @@ -1673,8 +1619,6 @@ gtk_window_focus_in_callback( GtkWidget * WXUNUSED(widget), GdkEventFocus *WXUNUSED(event), wxWindow *win ) { - DEBUG_MAIN_THREAD - if (win->m_imData) gtk_im_context_focus_in(win->m_imData->context); @@ -1723,8 +1667,6 @@ gtk_window_focus_out_callback( GtkWidget * WXUNUSED(widget), GdkEventFocus * WXUNUSED(gdk_event), wxWindowGTK *win ) { - DEBUG_MAIN_THREAD - if (win->m_imData) gtk_im_context_focus_out(win->m_imData->context); @@ -1887,8 +1829,6 @@ gtk_scrollbar_value_changed(GtkRange* range, wxWindow* win) static gboolean gtk_scrollbar_button_press_event(GtkRange*, GdkEventButton*, wxWindow* win) { - DEBUG_MAIN_THREAD - g_blockEventsOnScroll = true; win->m_mouseButtonDown = true; @@ -1922,8 +1862,6 @@ gtk_scrollbar_event_after(GtkRange* range, GdkEvent* event, wxWindow* win) static gboolean gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* win) { - DEBUG_MAIN_THREAD - g_blockEventsOnScroll = false; win->m_mouseButtonDown = false; // If thumb tracking @@ -1946,8 +1884,6 @@ gtk_scrollbar_button_release_event(GtkRange* range, GdkEventButton*, wxWindow* w static void gtk_window_realized_callback(GtkWidget* widget, wxWindow* win) { - DEBUG_MAIN_THREAD - if (win->m_imData) { gtk_im_context_set_client_window( win->m_imData->context, @@ -2174,7 +2110,6 @@ void wxWindowGTK::Init() m_noExpose = false; m_nativeSizeEvent = false; - m_hasScrolling = false; m_isScrolling = false; m_mouseButtonDown = false; @@ -2230,7 +2165,7 @@ bool wxWindowGTK::Create( wxWindow *parent, wxBorder border = GetBorder(style); style &= ~wxBORDER_MASK; style |= border; - + if (!PreCreation( parent, pos, size ) || !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) { @@ -2245,7 +2180,6 @@ bool wxWindowGTK::Create( wxWindow *parent, else { m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); - gtk_container_set_resize_mode(GTK_CONTAINER(m_widget), GTK_RESIZE_QUEUE); GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget); @@ -2767,19 +2701,27 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const if (m_wxwindow) { - int dw = 0; - int dh = 0; - - if (m_hasScrolling) - GetScrollbarWidth(m_widget, dw, dh); + // if window is scrollable, account for scrollbars + for (int i = 0; i < 2 && m_scrollBar[i]; i++) + { + GtkRequisition req; + GtkAdjustment* adj = gtk_range_get_adjustment(m_scrollBar[i]); + // if scrollbar enabled + if (adj->upper > adj->page_size) + { + gtk_widget_size_request(GTK_WIDGET(m_scrollBar[i]), &req); + if (i == ScrollDir_Horz) + h -= req.height; + else + w -= req.width; + } + } int border_x, border_y; WX_PIZZA(m_wxwindow)->get_border_widths(border_x, border_y); - dw += 2 * border_x; - dh += 2 * border_y; + w -= 2 * border_x; + h -= 2 * border_y; - w -= dw; - h -= dh; if (w < 0) w = 0; if (h < 0) @@ -2911,19 +2853,16 @@ bool wxWindowGTK::Show( bool show ) return false; } - if (show) + if (show && m_showOnIdle) { - if (!m_showOnIdle) - { - gtk_widget_show( m_widget ); - wxShowEvent eventShow(GetId(), show); - eventShow.SetEventObject(this); - HandleWindowEvent(eventShow); - } + // deferred } else { - gtk_widget_hide( m_widget ); + if (show) + gtk_widget_show(m_widget); + else + gtk_widget_hide(m_widget); wxShowEvent eventShow(GetId(), show); eventShow.SetEventObject(this); HandleWindowEvent(eventShow); @@ -4036,11 +3975,7 @@ void wxWindowGTK::SetScrollbar(int orient, GtkRange* const sb = m_scrollBar[dir]; wxCHECK_RET( sb, _T("this window is not scrollable") ); - if (range > 0) - { - m_hasScrolling = true; - } - else + if (range <= 0) { // GtkRange requires upper > lower range = @@ -4119,8 +4054,6 @@ static inline bool IsScrollIncrement(double increment, double x) wxEventType wxWindowGTK::GetScrollEventType(GtkRange* range) { - DEBUG_MAIN_THREAD - wxASSERT(range == m_scrollBar[0] || range == m_scrollBar[1]); const int barIndex = range == m_scrollBar[1];