Hide cursor while warping on Wayland
Based on https://gitlab.freedesktop.org/xorg/xserver/-/issues/734 we
hide the window cursor prior to warping, which allows XWayland to
reposition the cursor. This is only performed when Wayland is detected;
all other configurations call the standard warp routine
Fixes https://gitlab.com/kicad/code/kicad/issues/9785
(cherry picked from commit a118f20464
)
This commit is contained in:
parent
83f135315c
commit
70b69af313
|
@ -248,7 +248,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
if( !justWarped )
|
if( !justWarped )
|
||||||
{
|
{
|
||||||
m_parentPanel->WarpPointer( x + warpX, y + warpY );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, x + warpX, y + warpY );
|
||||||
m_dragStartPoint += VECTOR2D( warpX, warpY );
|
m_dragStartPoint += VECTOR2D( warpX, warpY );
|
||||||
justWarped = true;
|
justWarped = true;
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
|
||||||
{
|
{
|
||||||
if( !justWarped )
|
if( !justWarped )
|
||||||
{
|
{
|
||||||
m_parentPanel->WarpPointer( x, y + warpY );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, x, y + warpY );
|
||||||
m_dragStartPoint += VECTOR2D( 0, warpY );
|
m_dragStartPoint += VECTOR2D( 0, warpY );
|
||||||
justWarped = true;
|
justWarped = true;
|
||||||
}
|
}
|
||||||
|
@ -741,17 +741,17 @@ void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordin
|
||||||
if( aWarpView )
|
if( aWarpView )
|
||||||
{
|
{
|
||||||
m_view->SetCenter( clampedPosition );
|
m_view->SetCenter( clampedPosition );
|
||||||
m_parentPanel->WarpPointer( screenSize.x / 2, screenSize.y / 2 );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, screenSize.x / 2, screenSize.y / 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_parentPanel->WarpPointer( screenPos.x, screenPos.y );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, screenPos.x, screenPos.y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_parentPanel->WarpPointer( aPosition.x, aPosition.y );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, aPosition.x, aPosition.y );
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshMouse();
|
refreshMouse();
|
||||||
|
@ -766,7 +766,7 @@ void WX_VIEW_CONTROLS::CenterOnCursor() const
|
||||||
if( GetMousePosition( false ) != screenCenter )
|
if( GetMousePosition( false ) != screenCenter )
|
||||||
{
|
{
|
||||||
m_view->SetCenter( GetCursorPosition() );
|
m_view->SetCenter( GetCursorPosition() );
|
||||||
m_parentPanel->WarpPointer( KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -877,7 +877,7 @@ void WX_VIEW_CONTROLS::handleCursorCapture( int x, int y )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( warp )
|
if( warp )
|
||||||
m_parentPanel->WarpPointer( x, y );
|
KIPLATFORM::UI::WarpPointer( m_parentPanel, x, y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gdk/gdk.h>
|
||||||
|
|
||||||
bool KIPLATFORM::UI::IsDarkTheme()
|
bool KIPLATFORM::UI::IsDarkTheme()
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,7 @@ bool KIPLATFORM::UI::IsStockCursorOk( wxStockCursor aCursor )
|
||||||
case wxCURSOR_BULLSEYE:
|
case wxCURSOR_BULLSEYE:
|
||||||
case wxCURSOR_HAND:
|
case wxCURSOR_HAND:
|
||||||
case wxCURSOR_ARROW:
|
case wxCURSOR_ARROW:
|
||||||
|
case wxCURSOR_BLANK:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -134,3 +135,26 @@ void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay
|
||||||
gtk_scrolled_window_set_overlay_scrolling( GTK_SCROLLED_WINDOW( aWindow->GetHandle() ),
|
gtk_scrolled_window_set_overlay_scrolling( GTK_SCROLLED_WINDOW( aWindow->GetHandle() ),
|
||||||
overlay );
|
overlay );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
|
||||||
|
{
|
||||||
|
if( !wxGetEnv( wxT( "WAYLAND_DISPLAY" ), nullptr ) )
|
||||||
|
{
|
||||||
|
aWindow->WarpPointer( aX, aY );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GdkDisplay* disp = gtk_widget_get_display( static_cast<GtkWidget*>( aWindow->GetHandle() ) );
|
||||||
|
GdkWindow* win = gdk_display_get_window_at_pointer( disp, nullptr, nullptr );
|
||||||
|
GdkCursor* blank_cursor = gdk_cursor_new_for_display( disp, GDK_BLANK_CURSOR );
|
||||||
|
GdkCursor* cur_cursor = gdk_window_get_cursor( win );
|
||||||
|
|
||||||
|
if( cur_cursor )
|
||||||
|
g_object_ref( cur_cursor );
|
||||||
|
|
||||||
|
gdk_window_set_cursor( win, blank_cursor );
|
||||||
|
aWindow->WarpPointer( aX, aY );
|
||||||
|
gdk_window_set_cursor( win, cur_cursor );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -116,6 +116,14 @@ namespace KIPLATFORM
|
||||||
* Implemented only on GTK.
|
* Implemented only on GTK.
|
||||||
*/
|
*/
|
||||||
void SetOverlayScrolling( const wxWindow* aWindow, bool overlay );
|
void SetOverlayScrolling( const wxWindow* aWindow, bool overlay );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move the mouse cursor to a specific position relative to the window
|
||||||
|
* @param aWindow Window in which to position to mouse cursor
|
||||||
|
* @param aX destination x position
|
||||||
|
* @param aY destination y position
|
||||||
|
*/
|
||||||
|
void WarpPointer( wxWindow* aWindow, int aX, int aY );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,3 +132,9 @@ void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
|
||||||
|
{
|
||||||
|
aWindow->WarpPointer( aX, aY );
|
||||||
|
}
|
||||||
|
|
|
@ -132,3 +132,9 @@ void KIPLATFORM::UI::SetOverlayScrolling( const wxWindow* aWindow, bool overlay
|
||||||
{
|
{
|
||||||
// Not implemented
|
// Not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KIPLATFORM::UI::WarpPointer( wxWindow* aWindow, int aX, int aY )
|
||||||
|
{
|
||||||
|
aWindow->WarpPointer( aX, aY );
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue