X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dc0c395d837af5097f3fb52bdc37a1faaa33869b..d9fda37ba1e29443ed473d3c69e71480935e09b7:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index fa22ff516e..b548b0460c 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -33,14 +33,10 @@ #include "wx/fontutil.h" #include "wx/sysopt.h" -#ifdef __WXDEBUG__ - #include "wx/thread.h" -#endif - #include #include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" +#include "wx/gtk/private/win_gtk.h" #include #include @@ -191,11 +187,6 @@ static bool g_captureWindowHasMouse = false; wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL; -// the last window which had the focus - this is normally never NULL (except -// if we never had focus at all) as even when g_focusWindow is NULL it still -// keeps its previous value -wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL; - // If a window get the focus set but has not been realized // yet, defer setting the focus to idle time. wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; @@ -205,23 +196,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 +253,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 +285,6 @@ gtk_window_expose_callback( GtkWidget*, GdkEventExpose *gdk_event, wxWindow *win ) { - DEBUG_MAIN_THREAD - #if 0 if (win->GetName()) { @@ -894,8 +841,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 +1053,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 +1220,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 +1574,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 +1582,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) @@ -1659,7 +1600,7 @@ window_scroll_event(GtkWidget*, GdkEventScroll* gdk_event, wxWindow* win) static gboolean wxgtk_window_popup_menu_callback(GtkWidget*, wxWindowGTK* win) { - wxContextMenuEvent event(wxEVT_CONTEXT_MENU, win->GetId(), wxGetMousePosition()); + wxContextMenuEvent event(wxEVT_CONTEXT_MENU, win->GetId(), wxPoint(-1, -1)); event.SetEventObject(win); return win->GTKProcessEvent(event); } @@ -1673,12 +1614,9 @@ 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); - g_focusWindowLast = g_focusWindow = win; wxLogTrace(TRACE_FOCUS, @@ -1723,8 +1661,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 +1823,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 +1856,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 +1878,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 +2104,6 @@ void wxWindowGTK::Init() m_noExpose = false; m_nativeSizeEvent = false; - m_hasScrolling = false; m_isScrolling = false; m_mouseButtonDown = false; @@ -2230,7 +2159,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 )) { @@ -2736,7 +2665,7 @@ void wxWindowGTK::OnInternalIdle() } } - if (wxUpdateUIEvent::CanUpdate(this) && IsShown()) + if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen()) UpdateWindowUI(wxUPDATE_UI_FROMIDLE); } @@ -2766,19 +2695,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) @@ -4032,11 +3969,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 = @@ -4115,8 +4048,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];