X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/989d151ce264820d43f01b5378aa8efc2c774d33..74a8f67d96591cec101def2a7d47c64072aff7fd:/src/gtk/window.cpp diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index e63968f3b9..ed62554673 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -343,9 +343,12 @@ expose_event_border(GtkWidget* widget, GdkEventExpose* gdk_event, wxWindow* win) // for scrollable ones detail = "viewport"; + // clip rect is required to avoid painting background + // over upper left (w,h) of parent window + GdkRectangle clipRect = { x, y, w, h }; gtk_paint_shadow( gtk_widget_get_style(win->m_wxwindow), gdk_event->window, GTK_STATE_NORMAL, - shadow, NULL, wxGTKPrivate::GetEntryWidget(), detail, x, y, w, h); + shadow, &clipRect, wxGTKPrivate::GetEntryWidget(), detail, x, y, w, h); } return false; } @@ -679,12 +682,6 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event, wxWindowGTK *win, GdkEventKey *gdk_event) { - int x = 0; - int y = 0; - GdkModifierType state; - if (gdk_event->window) - gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - event.SetTimestamp( gdk_event->time ); event.SetId(win->GetId()); @@ -738,10 +735,8 @@ static void wxFillOtherKeyEventFields(wxKeyEvent& event, event.m_rawCode = (wxUint32) gdk_event->keyval; event.m_rawFlags = gdk_event->hardware_keycode; - wxGetMousePosition( &x, &y ); - win->ScreenToClient( &x, &y ); - event.m_x = x; - event.m_y = y; + wxGetMousePosition(&event.m_x, &event.m_y); + win->ScreenToClient(&event.m_x, &event.m_y); event.SetEventObject( win ); } @@ -1142,6 +1137,10 @@ template void InitMouseEvent(wxWindowGTK *win, event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK) != 0; event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK) != 0; event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK) != 0; + + // In gdk/win32 VK_XBUTTON1 is translated to GDK_BUTTON4_MASK + // and VK_XBUTTON2 to GDK_BUTTON5_MASK. In x11/gdk buttons 4/5 + // are wheel rotation and buttons 8/9 don't change the state. event.m_aux1Down = (gdk_event->state & GDK_BUTTON4_MASK) != 0; event.m_aux2Down = (gdk_event->state & GDK_BUTTON5_MASK) != 0; @@ -1193,6 +1192,20 @@ static void AdjustEventButtonState(wxMouseEvent& event) event.m_rightDown = !event.m_rightDown; return; } + + if ((event.GetEventType() == wxEVT_AUX1_DOWN) || + (event.GetEventType() == wxEVT_AUX1_DCLICK)) + { + event.m_aux1Down = true; + return; + } + + if ((event.GetEventType() == wxEVT_AUX2_DOWN) || + (event.GetEventType() == wxEVT_AUX2_DCLICK)) + { + event.m_aux2Down = true; + return; + } } // find the window to send the mouse event too @@ -1422,6 +1435,42 @@ gtk_window_button_press_callback( GtkWidget *widget, } } + else if (gdk_event->button == 8) + { + switch (gdk_event->type) + { + case GDK_3BUTTON_PRESS: + case GDK_BUTTON_PRESS: + event_type = wxEVT_AUX1_DOWN; + break; + + case GDK_2BUTTON_PRESS: + event_type = wxEVT_AUX1_DCLICK; + break; + + default: + ; + } + } + + else if (gdk_event->button == 9) + { + switch (gdk_event->type) + { + case GDK_3BUTTON_PRESS: + case GDK_BUTTON_PRESS: + event_type = wxEVT_AUX2_DOWN; + break; + + case GDK_2BUTTON_PRESS: + event_type = wxEVT_AUX2_DCLICK; + break; + + default: + ; + } + } + if ( event_type == wxEVT_NULL ) { // unknown mouse button or click type @@ -1505,6 +1554,14 @@ gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget), event_type = wxEVT_RIGHT_UP; break; + case 8: + event_type = wxEVT_AUX1_UP; + break; + + case 9: + event_type = wxEVT_AUX2_UP; + break; + default: // unknown button, don't process return FALSE; @@ -2035,6 +2092,7 @@ wxMouseState wxGetMouseState() ms.SetLeftDown((mask & GDK_BUTTON1_MASK) != 0); ms.SetMiddleDown((mask & GDK_BUTTON2_MASK) != 0); ms.SetRightDown((mask & GDK_BUTTON3_MASK) != 0); + // see the comment in InitMouseEvent() ms.SetAux1Down((mask & GDK_BUTTON4_MASK) != 0); ms.SetAux2Down((mask & GDK_BUTTON5_MASK) != 0); @@ -2457,8 +2515,6 @@ void wxWindowGTK::ConnectWidget( GtkWidget *widget ) bool wxWindowGTK::Destroy() { - wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - m_hasVMT = false; return wxWindowBase::Destroy(); @@ -2885,7 +2941,7 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); wxFont font = GetFont(); - wxCHECK_MSG( font.Ok(), 12, wxT("invalid font") ); + wxCHECK_MSG( font.IsOk(), 12, wxT("invalid font") ); PangoContext* context = gtk_widget_get_pango_context(m_widget); @@ -2911,7 +2967,7 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); wxFont font = GetFont(); - wxCHECK_MSG( font.Ok(), 8, wxT("invalid font") ); + wxCHECK_MSG( font.IsOk(), 8, wxT("invalid font") ); PangoContext* context = gtk_widget_get_pango_context(m_widget); @@ -2941,7 +2997,7 @@ void wxWindowGTK::DoGetTextExtent( const wxString& string, { wxFont fontToUse = theFont ? *theFont : GetFont(); - wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); + wxCHECK_RET( fontToUse.IsOk(), wxT("invalid font") ); if (string.empty()) { @@ -3202,8 +3258,7 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) { wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") ); - wxWindowGTK *oldParent = m_parent, - *newParent = (wxWindowGTK *)newParentBase; + wxWindowGTK * const newParent = (wxWindowGTK *)newParentBase; wxASSERT( GTK_IS_WIDGET(m_widget) ); @@ -3212,8 +3267,11 @@ bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) wxASSERT( GTK_IS_WIDGET(m_widget) ); - if (oldParent) - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(m_widget)), m_widget); + // Notice that old m_parent pointer might be non-NULL here but the widget + // still not have any parent at GTK level if it's a notebook page that had + // been removed from the notebook so test this at GTK level and not wx one. + if ( GtkWidget *parentGTK = gtk_widget_get_parent(m_widget) ) + gtk_container_remove(GTK_CONTAINER(parentGTK), m_widget); wxASSERT( GTK_IS_WIDGET(m_widget) ); @@ -3377,9 +3435,11 @@ void wxWindowGTK::RealizeTabOrder() { wxWindowGTK *win = *i; + bool focusableFromKeyboard = win->AcceptsFocusFromKeyboard(); + if ( mnemonicWindow ) { - if ( win->AcceptsFocusFromKeyboard() ) + if ( focusableFromKeyboard ) { // wxComboBox et al. needs to focus on on a different // widget than m_widget, so if the main widget isn't @@ -3404,7 +3464,8 @@ void wxWindowGTK::RealizeTabOrder() mnemonicWindow = win; } - chain = g_list_prepend(chain, win->m_widget); + if ( focusableFromKeyboard ) + chain = g_list_prepend(chain, win->m_widget); } chain = g_list_reverse(chain); @@ -3449,7 +3510,7 @@ void wxWindowGTK::Lower() bool wxWindowGTK::SetCursor( const wxCursor &cursor ) { - if ( !wxWindowBase::SetCursor(cursor.Ok() ? cursor : *wxSTANDARD_CURSOR) ) + if ( !wxWindowBase::SetCursor(cursor.IsOk() ? cursor : *wxSTANDARD_CURSOR) ) return false; GTKUpdateCursor(); @@ -3461,8 +3522,8 @@ void wxWindowGTK::GTKUpdateCursor(bool update_self /*=true*/, bool recurse /*=tr { if (update_self) { - wxCursor cursor(g_globalCursor.Ok() ? g_globalCursor : GetCursor()); - if ( cursor.Ok() ) + wxCursor cursor(g_globalCursor.IsOk() ? g_globalCursor : GetCursor()); + if ( cursor.IsOk() ) { wxArrayGdkWindows windowsThis; GdkWindow* window = GTKGetWindow(windowsThis); @@ -3794,7 +3855,7 @@ bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) if (!wxWindowBase::SetBackgroundColour(colour)) return false; - if (colour.Ok()) + if (colour.IsOk()) { // We need the pixel value e.g. for background clearing. m_backgroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); @@ -3816,7 +3877,7 @@ bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) return false; } - if (colour.Ok()) + if (colour.IsOk()) { // We need the pixel value e.g. for background clearing. m_foregroundColour.CalcPixel(gtk_widget_get_colormap(m_widget)); @@ -3838,15 +3899,15 @@ GtkRcStyle *wxWindowGTK::GTKCreateWidgetStyle(bool forceStyle) { // do we need to apply any changes at all? if ( !forceStyle && - !m_font.Ok() && - !m_foregroundColour.Ok() && !m_backgroundColour.Ok() ) + !m_font.IsOk() && + !m_foregroundColour.IsOk() && !m_backgroundColour.IsOk() ) { return NULL; } GtkRcStyle *style = gtk_rc_style_new(); - if ( m_font.Ok() ) + if ( m_font.IsOk() ) { style->font_desc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); @@ -3857,7 +3918,7 @@ GtkRcStyle *wxWindowGTK::GTKCreateWidgetStyle(bool forceStyle) flagsActive = 0, flagsInsensitive = 0; - if ( m_foregroundColour.Ok() ) + if ( m_foregroundColour.IsOk() ) { const GdkColor *fg = m_foregroundColour.GetColor(); @@ -3874,7 +3935,7 @@ GtkRcStyle *wxWindowGTK::GTKCreateWidgetStyle(bool forceStyle) flagsActive |= GTK_RC_FG | GTK_RC_TEXT; } - if ( m_backgroundColour.Ok() ) + if ( m_backgroundColour.IsOk() ) { const GdkColor *bg = m_backgroundColour.GetColor(); @@ -4128,7 +4189,7 @@ void wxWindowGTK::DoCaptureMouse() wxCHECK_RET( window, wxT("CaptureMouse() failed") ); const wxCursor* cursor = &m_cursor; - if (!cursor->Ok()) + if (!cursor->IsOk()) cursor = wxSTANDARD_CURSOR; gdk_pointer_grab( window, FALSE,