Allow overlay scrolling on GTK, except for GAL canvases.

This prevents glitches when both scrollbars
are visible and scrolling to the end.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/10559

Fixes https://gitlab.com/kicad/code/kicad/-/issues/9988
This commit is contained in:
Alex 2022-01-31 18:45:47 +03:00
parent a8486c5296
commit 4c4089e836
6 changed files with 26 additions and 4 deletions

View File

@ -94,6 +94,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
ShowScrollbars( wxSHOW_SB_ALWAYS, wxSHOW_SB_ALWAYS );
EnableScrolling( false, false ); // otherwise Zoom Auto disables GAL canvas
KIPLATFORM::UI::SetOverlayScrolling( this, false ); // Prevent excessive repaint on GTK
Connect( wxEVT_SIZE, wxSizeEventHandler( EDA_DRAW_PANEL_GAL::onSize ), nullptr, this );
Connect( wxEVT_ENTER_WINDOW, wxMouseEventHandler( EDA_DRAW_PANEL_GAL::onEnter ), nullptr,

View File

@ -39,10 +39,6 @@ void KIPLATFORM::ENV::Init()
// required until wxWidgets supports the Wayland compositors
wxSetEnv( wxT( "GDK_BACKEND" ), wxT( "x11" ) );
// Disable overlay scrollbars as they mess up wxWidgets window sizing and cause
// excessive redraw requests.
wxSetEnv( wxT( "GTK_OVERLAY_SCROLLING" ), wxT( "0" ) );
// Set GTK2-style input instead of xinput2. This disables touchscreen and smooth
// scrolling. It's needed to ensure that we are not getting multiple mouse scroll
// events.

View File

@ -127,3 +127,10 @@ wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) );
}
void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
{
gtk_scrolled_window_set_overlay_scrolling( GTK_SCROLLED_WINDOW( aWindow->GetHandle() ),
overlay );
}

View File

@ -109,6 +109,12 @@ namespace KIPLATFORM
* @return Viewport size that won't be obscured by scrollbars
*/
wxSize GetUnobscuredSize( const wxWindow* aWindow );
/**
* Used to set overlay/non-overlay scrolling mode in a window.
* Implemented only on GTK.
*/
void SetOverlayScrolling( const wxWindow* aWindow, bool overlay );
}
}

View File

@ -126,3 +126,9 @@ wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
{
return aWindow->GetClientSize();
}
void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
{
// Not implemented
}

View File

@ -126,3 +126,9 @@ wxSize KIPLATFORM::UI::GetUnobscuredSize( const wxWindow* aWindow )
return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) );
}
void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay )
{
// Not implemented
}