24#include <wx/dataview.h>
26#include <wx/nonownedwnd.h>
27#include <wx/popupwin.h>
28#include <wx/settings.h>
35#ifdef GDK_WINDOWING_X11
41#ifdef GDK_WINDOWING_WAYLAND
42#include <gdk/gdkwayland.h>
51static const wxChar
traceRhi[] = wxT(
"KICAD_RHI" );
56 wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
59 double brightness = ( bg.Red() / 255.0 ) * 0.299 +
60 ( bg.Green() / 255.0 ) * 0.587 +
61 ( bg.Blue() / 255.0 ) * 0.117;
63 return brightness < 0.5;
69 return wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
77#if( GTK_CHECK_VERSION( 3, 24, 0 ) )
79 GtkWidgetPath*
path = gtk_widget_path_new();
80 GtkStyleContext* sc = gtk_style_context_new();
82 gtk_widget_path_append_type(
path, GTK_TYPE_WINDOW );
83 gtk_widget_path_iter_set_object_name(
path, -1,
"infobar" );
84 gtk_widget_path_iter_add_class(
path, -1,
"info" );
86 gtk_style_context_set_path( sc,
path );
87 gtk_style_context_set_state( sc, GTK_STATE_FLAG_NORMAL );
89 gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL,
"background-color", &rgba, NULL );
90 aBgColour = wxColour( *rgba );
91 gdk_rgba_free( rgba );
93 gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL,
"color", &rgba, NULL );
94 aFgColour = wxColour( *rgba );
95 gdk_rgba_free( rgba );
100 if( aBgColour.Alpha() == 0 )
102 gtk_widget_path_append_type(
path, G_TYPE_NONE );
103 gtk_widget_path_iter_set_object_name(
path, -1,
"revealer" );
104 gtk_widget_path_append_type(
path, G_TYPE_NONE );
105 gtk_widget_path_iter_set_object_name(
path, -1,
"box" );
107 gtk_style_context_set_path( sc,
path );
108 gtk_style_context_set_state( sc, GTK_STATE_FLAG_NORMAL );
110 gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL,
"background-color", &rgba, NULL );
111 aBgColour = wxColour( *rgba );
112 gdk_rgba_free( rgba );
114 gtk_style_context_get( sc, GTK_STATE_FLAG_NORMAL,
"color", &rgba, NULL );
115 aFgColour = wxColour( *rgba );
116 gdk_rgba_free( rgba );
119 gtk_widget_path_free(
path );
120 g_object_unref( sc );
123 aBgColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOBK );
124 aFgColour = wxSystemSettings::GetColour( wxSYS_COLOUR_INFOTEXT );
130#ifdef GDK_WINDOWING_WAYLAND
133class CANVAS_OVERLAY :
public wxPopupWindow
136 CANVAS_OVERLAY( wxWindow* aCanvas ) :
137 wxPopupWindow( aCanvas )
140 gtk_window_set_type_hint( GTK_WINDOW( m_widget ), GDK_WINDOW_TYPE_HINT_NORMAL );
142 aCanvas->Bind( wxEVT_SIZE, &CANVAS_OVERLAY::onCanvasSize,
this );
143 g_signal_connect( aCanvas->GetHandle(),
"map", G_CALLBACK( onCanvasMap ),
this );
146 ~CANVAS_OVERLAY()
override
148 GetParent()->Unbind( wxEVT_SIZE, &CANVAS_OVERLAY::onCanvasSize,
this );
149 g_signal_handlers_disconnect_by_data( GetParent()->GetHandle(),
this );
152 void Raise()
override
155 CallAfter( &CANVAS_OVERLAY::remap );
158 bool Show(
bool aShow =
true )
override
163 return wxPopupWindow::Show( aShow );
167 static void onCanvasMap( GtkWidget* aWidget, gpointer aOverlay )
169 static_cast<CANVAS_OVERLAY*
>( aOverlay )->Raise();
172 void onCanvasSize( wxSizeEvent& aEvent )
181 if( gtk_widget_get_mapped( GetParent()->GetHandle() ) )
182 Move( GetParent()->ClientToScreen( wxPoint( 0, 0 ) ) );
199#ifdef GDK_WINDOWING_WAYLAND
200 if( GDK_IS_WAYLAND_DISPLAY( gdk_display_get_default() ) )
201 return new CANVAS_OVERLAY( aCanvas );
215 wxWindow* tlw = aWindow;
217 while( tlw && !tlw->IsTopLevel() )
218 tlw = tlw->GetParent();
222 GtkWidget* widget =
static_cast<GtkWidget*
>( tlw->GetHandle() );
224 if( widget && GTK_IS_WINDOW( widget ) )
225 gtk_window_present( GTK_WINDOW( widget ) );
235 GtkWindow* window = GTK_WINDOW( aWindow->GetHandle() );
238 return gtk_window_is_active( window );
256 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
258 if( widget && GTK_IS_WINDOW( widget ) )
259 gtk_window_set_gravity( GTK_WINDOW( widget ), GDK_GRAVITY_STATIC );
272 const char*
id =
static_cast<const char*
>( g_object_get_data( G_OBJECT( aWidget ),
278 GdkWindow* window = gtk_widget_get_window( aWidget );
283#ifdef GDK_WINDOWING_X11
284 if( GDK_IS_X11_WINDOW( window ) )
288 if( XClassHint* hints = XAllocClassHint() )
290 hints->res_name =
const_cast<char*
>( id );
291 hints->res_class =
const_cast<char*
>( id );
293 XSetClassHint( GDK_WINDOW_XDISPLAY( window ), GDK_WINDOW_XID( window ), hints );
299#if defined( GDK_WINDOWING_WAYLAND ) && GTK_CHECK_VERSION( 3, 24, 22 )
301 if( GDK_IS_WAYLAND_WINDOW( window ) && gtk_check_version( 3, 24, 22 ) ==
nullptr )
302 gdk_wayland_window_set_application_id( window,
id );
309 if( !aWindow || aClass.IsEmpty() )
312 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
319 g_object_set_data_full( G_OBJECT( widget ),
WM_CLASS_DATA_KEY, g_strdup( aClass.utf8_str() ),
323 g_signal_handlers_disconnect_by_func( widget,
reinterpret_cast<void*
>(
setWindowClassHint ),
326 g_signal_connect_after( widget,
"realize", G_CALLBACK(
setWindowClassHint ),
nullptr );
330 if( gtk_widget_get_realized( widget ) )
357 case wxCURSOR_BULLSEYE:
379 GtkMenuItem* pMenuItem = GTK_MENU_ITEM( pItem );
380 GtkWidget* child = gtk_bin_get_child( GTK_BIN( pMenuItem ) );
381 GtkCellView* pCellView = GTK_CELL_VIEW( child );
382 GtkCellLayout* pCellLayout = GTK_CELL_LAYOUT( pCellView );
383 GtkCellArea* pCellArea = gtk_cell_layout_get_area( pCellLayout );
385 g_signal_handlers_block_matched( pCellArea, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, userdata );
391 AtkObject* atkObj = gtk_combo_box_get_popup_accessible( GTK_COMBO_BOX( aChoice->m_widget ) );
393 if( !atkObj || !GTK_IS_ACCESSIBLE( atkObj ) )
396 GtkWidget* widget = gtk_accessible_get_widget( GTK_ACCESSIBLE( atkObj ) );
398 if( !widget || !GTK_IS_MENU( widget ) )
401 GtkMenu* menu = GTK_MENU( widget );
411 GList* cells = gtk_cell_layout_get_cells( GTK_CELL_LAYOUT( aChoice->m_widget ) );
416 GtkCellRenderer* cell = (GtkCellRenderer*) cells->data;
421 g_object_set( G_OBJECT( cell ),
"ellipsize", PANGO_ELLIPSIZE_END,
nullptr );
424 g_list_free( cells );
432 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
434 if( widget && gtk_check_version( 3, 10, 0 ) ==
nullptr )
435 val = gtk_widget_get_scale_factor( widget );
450#if GTK_CHECK_VERSION( 3, 22, 0 )
451 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
452 GdkWindow* window = widget ? gtk_widget_get_window( widget ) :
nullptr;
457 GdkMonitor* monitor = gdk_display_get_monitor_at_window( gdk_window_get_display( window ), window );
460 return monitor ? gdk_monitor_get_refresh_rate( monitor ) / 1000.0 : 0.0;
469 return wxSize( aWindow->GetSize().GetX() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X ),
470 aWindow->GetSize().GetY() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y ) );
476 gtk_scrolled_window_set_overlay_scrolling( GTK_SCROLLED_WINDOW( aWindow->GetHandle() ),
483 gboolean allowed = 1;
485 g_object_get( gtk_settings_get_default(),
"gtk-menu-images", &allowed, NULL );
493#ifdef GDK_WINDOWING_X11
494 GdkDisplay* display = gdk_display_get_default();
496 return display && GDK_IS_X11_DISPLAY( display );
503#if defined( GDK_WINDOWING_WAYLAND ) && defined( KICAD_WAYLAND )
505static bool wayland_warp_pointer( GtkWidget* aWidget, GdkDisplay* aDisplay, GdkWindow* aWindow,
506 GdkDevice* aPtrDev,
int aX,
int aY );
510static wxPoint s_warped_from;
511static wxPoint s_warped_to;
515 wxPoint wx_pos = wxGetMousePosition();
517 if( wx_pos == s_warped_from )
519 wxLogTrace(
traceWayland, wxS(
"Faked mouse pos %d %d -> %d %d" ), wx_pos.x, wx_pos.y,
520 s_warped_to.x, s_warped_to.y );
527 s_warped_from = wxPoint();
528 s_warped_to = wxPoint();
539 if( !wxGetEnv( wxT(
"WAYLAND_DISPLAY" ),
nullptr ) )
541 aWindow->WarpPointer( aX, aY );
546 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
548 GdkDisplay* disp = gtk_widget_get_display( widget );
549 GdkSeat* seat = gdk_display_get_default_seat( disp );
550 GdkDevice* ptrdev = gdk_seat_get_pointer( seat );
552#if defined( GDK_WINDOWING_WAYLAND ) && defined( KICAD_WAYLAND )
553 if( GDK_IS_WAYLAND_DISPLAY( disp ) )
555 wxPoint initialPos = wxGetMousePosition();
556 GdkWindow* win = aWindow->GTKGetDrawingWindow();
558 if( wayland_warp_pointer( widget, disp, win, ptrdev, aX, aY ) )
560 s_warped_from = initialPos;
561 s_warped_to = aWindow->ClientToScreen( wxPoint( aX, aY ) );
563 wxLogTrace(
traceWayland, wxS(
"Set warped from %d %d to %d %d" ), s_warped_from.x,
564 s_warped_from.y, s_warped_to.x, s_warped_to.y );
569 wxLogTrace(
traceWayland, wxS(
"*** Warp to %d %d failed ***" ), aX, aY );
574#ifdef GDK_WINDOWING_X11
575 if( GDK_IS_X11_DISPLAY( disp ) )
577 GdkWindow* win = gdk_device_get_window_at_position( ptrdev,
nullptr,
nullptr );
581 aWindow->WarpPointer( aX, aY );
585 GdkCursor* blank_cursor = gdk_cursor_new_for_display( disp, GDK_BLANK_CURSOR );
586 GdkCursor* cur_cursor = gdk_window_get_cursor( win );
589 g_object_ref( cur_cursor );
591 gdk_window_set_cursor( win, blank_cursor );
592 aWindow->WarpPointer( aX, aY );
593 gdk_window_set_cursor( win, cur_cursor );
596 g_object_unref( cur_cursor );
599 g_object_unref( blank_cursor );
617 wxWindowGTK* win =
static_cast<wxWindowGTK*
>( aWindow );
620 GtkIMContext* imContext = win->m_imContext;
623 gtk_im_context_focus_out( imContext );
642 GtkWidget* widget =
static_cast<GtkWidget*
>( aDialog->GetHandle() );
644 if( widget && GTK_IS_FILE_CHOOSER( widget ) )
645 gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( widget ), FALSE );
654 GtkWidget* widget = aCtrl->GtkGetTreeView();
656 if( !widget || !GTK_IS_TREE_VIEW( widget ) )
659 GtkTreeView* view = GTK_TREE_VIEW( widget );
662 if( !gtk_tree_view_get_model( view ) )
665 GtkTreeViewColumn* column = gtk_tree_view_get_column( view, 0 );
676 gtk_widget_queue_resize( widget );
677 gtk_tree_view_scroll_to_cell( view,
nullptr, column, FALSE, 0.0, 0.0 );
684#if defined( GDK_WINDOWING_WAYLAND ) && defined( KICAD_WAYLAND )
686static bool s_wl_initialized =
false;
687static struct wl_compositor* s_wl_compositor = NULL;
688static struct zwp_pointer_constraints_v1* s_wl_pointer_constraints = NULL;
689static struct zwp_confined_pointer_v1* s_wl_confined_pointer = NULL;
690static struct wl_region* s_wl_confinement_region = NULL;
691static bool s_wl_locked_flag =
false;
693static void handle_global(
void* data,
struct wl_registry* registry, uint32_t
name,
694 const char* interface, uint32_t version )
696 wxLogTrace(
traceWayland,
"handle_global received %s name %u version %u", interface,
697 (
unsigned int)
name, (
unsigned int) version );
699 if( strcmp( interface, wl_compositor_interface.name ) == 0 )
701 s_wl_compositor =
static_cast<wl_compositor*
>(
702 wl_registry_bind( registry,
name, &wl_compositor_interface, version ) );
706 s_wl_pointer_constraints =
static_cast<zwp_pointer_constraints_v1*
>( wl_registry_bind(
711static void handle_global_remove(
void*,
struct wl_registry*, uint32_t
name )
713 wxLogTrace(
traceWayland,
"handle_global_remove name %u", (
unsigned int)
name );
716static const struct wl_registry_listener registry_listener = {
717 .global = handle_global,
718 .global_remove = handle_global_remove,
721static void confined_handler(
void* data,
struct zwp_confined_pointer_v1* zwp_confined_pointer_v1 )
726static void unconfined_handler(
void* data,
727 struct zwp_confined_pointer_v1* zwp_confined_pointer_v1 )
729 wxLogTrace(
traceWayland, wxS(
"Pointer unconfined" ) );
733 .confined = confined_handler,
734 .unconfined = unconfined_handler
737static void locked_handler(
void* data,
struct zwp_locked_pointer_v1* zwp_locked_pointer_v1 )
739 s_wl_locked_flag =
true;
743static void unlocked_handler(
void* data,
struct zwp_locked_pointer_v1* zwp_locked_pointer_v1 )
749 .locked = locked_handler,
750 .unlocked = unlocked_handler
757static void initialize_wayland( wl_display* wldisp )
759 if( s_wl_initialized )
764 struct wl_registry* registry = wl_display_get_registry( wldisp );
765 wl_registry_add_listener( registry, ®istry_listener, NULL );
766 wl_display_roundtrip( wldisp );
767 s_wl_initialized =
true;
771struct zwp_locked_pointer_v1* s_wl_locked_pointer = NULL;
773static int s_after_paint_handler_id = 0;
775static void on_frame_clock_after_paint( GdkFrameClock* clock, GtkWidget* widget )
777 if( s_wl_locked_pointer )
780 s_wl_locked_pointer = NULL;
782 wxLogTrace(
traceWayland, wxS(
"after-paint: locked_pointer destroyed" ) );
784 g_signal_handler_disconnect( (gpointer) clock, s_after_paint_handler_id );
785 s_after_paint_handler_id = 0;
788 if( s_wl_confinement_region != NULL )
790 wxLogTrace(
traceWayland, wxS(
"after-paint: Restoring confinement" ) );
792 GdkDisplay* disp = gtk_widget_get_display( widget );
793 GdkSeat* seat = gdk_display_get_default_seat( disp );
794 GdkDevice* ptrdev = gdk_seat_get_pointer( seat );
795 GdkWindow* window = gtk_widget_get_window( widget );
797 wl_display* wldisp = gdk_wayland_display_get_wl_display( disp );
798 wl_surface* wlsurf = gdk_wayland_window_get_wl_surface( window );
799 wl_pointer* wlptr = gdk_wayland_device_get_wl_pointer( ptrdev );
802 s_wl_pointer_constraints, wlsurf, wlptr, s_wl_confinement_region,
805 wl_display_roundtrip( wldisp );
811static bool wayland_warp_pointer( GtkWidget* aWidget, GdkDisplay* aDisplay, GdkWindow* aWindow,
812 GdkDevice* aPtrDev,
int aX,
int aY )
814 wl_display* wldisp = gdk_wayland_display_get_wl_display( aDisplay );
815 wl_surface* wlsurf = gdk_wayland_window_get_wl_surface( aWindow );
816 wl_pointer* wlptr = gdk_wayland_device_get_wl_pointer( aPtrDev );
818 if( s_after_paint_handler_id )
821 wxLogTrace(
traceWayland, wxS(
"Not warping: after-paint pending" ) );
825 initialize_wayland( wldisp );
827 if( s_wl_locked_pointer )
830 wxLogTrace(
traceWayland, wxS(
"** Destroying previous locked_pointer **" ) );
832 wl_display_roundtrip( wldisp );
833 s_wl_locked_pointer = NULL;
838 GdkFrameClock* frame_clock = gdk_window_get_frame_clock( aWindow );
839 s_after_paint_handler_id = g_signal_connect_after(
840 frame_clock,
"after-paint", G_CALLBACK( on_frame_clock_after_paint ), aWidget );
843 if( s_wl_confinement_region && s_wl_confined_pointer )
846 wl_display_roundtrip( wldisp );
847 s_wl_confined_pointer = NULL;
850 s_wl_locked_flag =
false;
852 s_wl_locked_pointer =
859 gtk_widget_translate_coordinates( aWidget, gtk_widget_get_toplevel( aWidget ), 0, 0, &wx, &wy );
862 wl_fixed_from_int( aY + wy ) );
865 wl_display_roundtrip( wldisp );
866 gtk_widget_queue_draw( aWidget );
869 return s_wl_locked_flag;
875 wxLogTrace(
traceWayland, wxS(
"InfiniteDragPrepareWindow" ) );
877 GtkWidget* widget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
878 GdkDisplay* disp = gtk_widget_get_display( widget );
880 if( GDK_IS_WAYLAND_DISPLAY( disp ) )
882 if( s_wl_confined_pointer != NULL )
887 GdkSeat* seat = gdk_display_get_default_seat( disp );
888 GdkDevice* ptrdev = gdk_seat_get_pointer( seat );
889 GdkWindow* win = aWindow->GTKGetDrawingWindow();
891 wl_display* wldisp = gdk_wayland_display_get_wl_display( disp );
892 wl_surface* wlsurf = gdk_wayland_window_get_wl_surface( win );
893 wl_pointer* wlptr = gdk_wayland_device_get_wl_pointer( ptrdev );
895 initialize_wayland( wldisp );
897 gint x, y, width, height;
898 gdk_window_get_geometry( gdk_window_get_toplevel( win ), &x, &y, &width, &height );
900 wxLogTrace(
traceWayland, wxS(
"Confine region: %d %d %d %d" ), x, y, width, height );
902 s_wl_confinement_region = wl_compositor_create_region( s_wl_compositor );
903 wl_region_add( s_wl_confinement_region, x, y, width, height );
906 s_wl_pointer_constraints, wlsurf, wlptr, s_wl_confinement_region,
912 wl_display_roundtrip( wldisp );
914 else if( wxGetEnv( wxT(
"WAYLAND_DISPLAY" ),
nullptr ) )
926 wxLogTrace(
traceWayland, wxS(
"InfiniteDragReleaseWindow" ) );
928 if( s_wl_confined_pointer )
931 s_wl_confined_pointer = NULL;
934 if( s_wl_confinement_region )
936 wl_region_destroy( s_wl_confinement_region );
937 s_wl_confinement_region = NULL;
948 return !wxGetEnv( wxT(
"WAYLAND_DISPLAY" ),
nullptr );
960 return wxGetMousePosition();
979 GtkWidget* gtkWidget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
984 gtk_widget_realize( gtkWidget );
985 GdkWindow* gdkWindow = gtk_widget_get_window( gtkWidget );
990 if( !gdk_window_ensure_native( gdkWindow ) )
992 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: gdk_window_ensure_native failed "
993 "widget=%p window=%p" ),
994 static_cast<void*
>( gtkWidget ),
995 static_cast<void*
>( gdkWindow ) );
999 if( !gdk_window_is_viewable( gdkWindow ) )
1003 if( !gtk_widget_get_visible( gtkWidget ) )
1005 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: widget hidden, skipping "
1006 "native window map widget=%p window=%p" ),
1007 static_cast<void*
>( gtkWidget ),
1008 static_cast<void*
>( gdkWindow ) );
1012 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: mapping native window "
1013 "widget=%p window=%p mapped=%s viewable=%s" ),
1014 static_cast<void*
>( gtkWidget ),
1015 static_cast<void*
>( gdkWindow ),
1016 gtk_widget_get_mapped( gtkWidget ) ?
"yes" :
"no",
1017 gdk_window_is_viewable( gdkWindow ) ?
"yes" :
"no" );
1019 gdk_window_show_unraised( gdkWindow );
1021 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: native window map result "
1022 "window=%p viewable=%s" ),
1023 static_cast<void*
>( gdkWindow ),
1024 gdk_window_is_viewable( gdkWindow ) ?
"yes" :
"no" );
1027 GdkDisplay* gdkDisplay = gtk_widget_get_display( gtkWidget );
1030 gdk_display_flush( gdkDisplay );
1032#ifdef GDK_WINDOWING_X11
1033 if( GDK_IS_X11_DISPLAY( gdkDisplay ) )
1035 *aHandle =
reinterpret_cast<void*
>( GDK_WINDOW_XID( gdkWindow ) );
1036 *aDisplay = gdk_x11_display_get_xdisplay( gdkDisplay );
1041 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: X11 widget=%p window=%p xid=0x%lx "
1043 static_cast<void*
>( gtkWidget ),
1044 static_cast<void*
>( gdkWindow ),
1045 static_cast<unsigned long>( GDK_WINDOW_XID( gdkWindow ) ),
1051#ifdef GDK_WINDOWING_WAYLAND
1052 if( GDK_IS_WAYLAND_DISPLAY( gdkDisplay ) )
1054 *aHandle = gdk_wayland_window_get_wl_surface( gdkWindow );
1055 *aDisplay = gdk_wayland_display_get_wl_display( gdkDisplay );
1060 wxLogTrace(
traceRhi, wxS(
"GetNativeWindowHandles: Wayland widget=%p window=%p "
1061 "surface=%p display=%p" ),
1062 static_cast<void*
>( gtkWidget ),
1063 static_cast<void*
>( gdkWindow ),
1077 GtkWidget* gtkWidget =
static_cast<GtkWidget*
>( aWindow->GetHandle() );
1081 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: no GtkWidget handle" ) );
1085 bool realized = gtk_widget_get_realized( gtkWidget );
1087 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: widget=%p realized=%s" ),
1088 static_cast<void*
>( gtkWidget ), realized ?
"yes" :
"no" );
1094 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
1095 gtk_widget_set_double_buffered( gtkWidget, FALSE );
1096 G_GNUC_END_IGNORE_DEPRECATIONS
1099 gtk_widget_set_app_paintable( gtkWidget, TRUE );
1101 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: double-buffering disabled, "
1102 "app-paintable enabled" ) );
1107 GdkWindow* gdkWindow = gtk_widget_get_window( gtkWidget );
1111#ifdef GDK_WINDOWING_X11
1112 if( GDK_IS_X11_DISPLAY( gdk_display_get_default() ) )
1116 Display* xDisplay = GDK_DISPLAY_XDISPLAY( gdk_display_get_default() );
1117 Window xWindow = GDK_WINDOW_XID( gdkWindow );
1118 XSetWindowBackgroundPixmap( xDisplay, xWindow,
None );
1120 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: X11 "
1121 "BackgroundPixmap set to None" ) );
1126 GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
1128 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
1129 gdk_window_set_background_rgba( gdkWindow, &black );
1130 G_GNUC_END_IGNORE_DEPRECATIONS
1132 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: GDK background "
1138 wxLogTrace(
traceRhi, wxS(
"PrepareForExternalRendering: no GdkWindow" ) );
1144 for( wxWindow* child : aWindow->GetChildren() )
1151#ifdef GDK_WINDOWING_X11
1152 if( !aChild || !aChild->GetParent() )
1155 GtkWidget* child =
static_cast<GtkWidget*
>( aChild->GetHandle() );
1156 GtkWidget* parent =
static_cast<GtkWidget*
>( aChild->GetParent()->GetHandle() );
1158 if( !child || !parent || !GDK_IS_X11_DISPLAY( gtk_widget_get_display( child ) ) )
1162 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
1163 const bool external = !gtk_widget_get_double_buffered( parent );
1164 G_GNUC_END_IGNORE_DEPRECATIONS
1169 GdkWindow* window = gtk_widget_get_window( child );
1172 if( !window || window == gtk_widget_get_window( parent ) )
1175 if( !gdk_window_ensure_native( window ) )
1176 wxLogTrace(
traceRhi, wxS(
"KeepAboveExternalRendering: gdk_window_ensure_native failed" ) );
static void zwp_confined_pointer_v1_destroy(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1)
Destroy the confined pointer object.
static int zwp_confined_pointer_v1_add_listener(struct zwp_confined_pointer_v1 *zwp_confined_pointer_v1, const struct zwp_confined_pointer_v1_listener *listener, void *data)
static void zwp_locked_pointer_v1_set_cursor_position_hint(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, wl_fixed_t surface_x, wl_fixed_t surface_y)
Set the cursor position hint relative to the top left corner of the surface.
static int zwp_locked_pointer_v1_add_listener(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, const struct zwp_locked_pointer_v1_listener *listener, void *data)
static void zwp_locked_pointer_v1_destroy(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
Destroy the locked pointer object.
static struct zwp_locked_pointer_v1 * zwp_pointer_constraints_v1_lock_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
The lock_pointer request lets the client request to disable movements of the virtual pointer (i....
static struct zwp_confined_pointer_v1 * zwp_pointer_constraints_v1_confine_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
The confine_pointer request lets the client request to confine the pointer cursor to a given region.
@ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT
the pointer constraint is defunct once deactivated
const wxChar *const traceRhi
Flag to enable debug output of the RHI rendering backend.
std::shared_ptr< PNS_LOG_VIEWER_OVERLAY > overlay
const struct wl_interface zwp_pointer_constraints_v1_interface
static const char *const WM_CLASS_DATA_KEY
static void setWindowClassHint(GtkWidget *aWidget, gpointer)
static void disable_area_apply_attributes_cb(GtkWidget *pItem, gpointer userdata)
The following two functions are based on the "hack" contained in the attached patch at https://gitlab...
const wxString traceWayland