]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
workaround the GTK2 GLWidget bug on Windows 133/head
authorThomas Debesse <dev@illwieckz.net>
Sun, 16 Jun 2019 15:40:08 +0000 (17:40 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 18 Jun 2019 21:39:26 +0000 (23:39 +0200)
CMakeLists.txt
Makefile
libs/gtkutil/window.cpp
libs/uilib/uilib.cpp
radiant/groupdialog.cpp
radiant/mainframe.cpp
radiant/texwindow.cpp
radiant/texwindow.h

index 2811bc3f837a3122b0b68d39b2c6e88f35849af2..4cbf3658077dcdd0dfe5b90ce91306cc31932470 100644 (file)
@@ -138,6 +138,10 @@ endif ()
 if (BUILD_RADIANT)
     set(GTK_TARGET 2 CACHE STRING "GTK target")
     add_definitions(-DGTK_TARGET=${GTK_TARGET})
+
+    if (GTK_TARGET EQUAL 2 AND WIN32)
+        add_definitions(-DWORKAROUND_WINDOWS_GTK2_GLWIDGET=1)
+    endif ()
 endif ()
 
 #-----------------------------------------------------------------------
index e8a1c5b09ac58693f3a1b96536cd204673e6cfd9..85049a8b2525fdba32b2d0b1f023b91aa6aa5eb0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -200,7 +200,7 @@ ifeq ($(OS),Linux)
 else
 
 ifeq ($(OS),Win32)
-       CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline
+       CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline -DWORKAROUND_WINDOWS_GTK2_GLWIDGET=1
        CFLAGS_COMMON += -mms-bitfields
        LDFLAGS_DLL = -Wl,--add-stdcall-alias
        LIBS_COMMON = -lws2_32 -luser32 -lgdi32 -lole32
index 11b6efeb21cd043373859011100ac7a7d676efd0..4c4536605fe799bcb6687b5c8b186b4137b98173 100644 (file)
 
 inline void CHECK_RESTORE( ui::Widget w ){
        if ( gpointer_to_int( g_object_get_data( G_OBJECT( w ), "was_mapped" ) ) != 0 ) {
+
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+               /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+               GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( w ), "glwidget" ) );
+               if ( glwidget ){
+                       gtk_widget_hide( glwidget );
+                       gtk_widget_show( glwidget );
+               }
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
+
                w.show();
        }
 }
index 1f4acb1fc7fec334f8501cd33d285bea319d40e3..8812911ed1e2bed878e6ad212aae77080ed5c08d 100644 (file)
@@ -87,6 +87,16 @@ namespace ui {
     void IWidget::visible(bool shown)
     {
         if (shown) {
+
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+            /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+            GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( this ), "glwidget" ) );
+            if ( glwidget ){
+                gtk_widget_hide( glwidget );
+                gtk_widget_show( glwidget );
+            }
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
+
             this.show();
         } else {
             this.hide();
index 1be74bf7caf67d3aec9ff561eca2f7c3252b8648..f6d9c4be8080d5137fb589d537a9c37d2da541ad 100644 (file)
@@ -169,9 +169,24 @@ void GroupDialog_setPage( ui::Widget page ){
        gtk_notebook_set_current_page( GTK_NOTEBOOK( g_GroupDlg.m_pNotebook ), gint( g_current_page ) );
 }
 
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+void GroupDialog_cycle();
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
+
 void GroupDialog_showPage( ui::Widget page ){
        if ( GroupDialog_getPage() == page ) {
                GroupDialog_ToggleShow();
+
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+               /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+               /* this is very ugly: cycle to next tab then return to current tab immediately to force the refresh
+                * this fixes the drawing of texture tab when window is restored and current tab is texture tab
+                * this is called for nothing when windows is minimized and called for nothing when current tab
+                * is not texture tab, hopefully it's a workaround that would disappear with gtk 3 */
+               GroupDialog_cycle();
+               GroupDialog_setPage( page );
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
+
        }
        else
        {
index d84fe69fbfa02201b0179fbe6f44d3682d883f46..6fadba47804fbd0c5784e4852127b451a2cbb17b 100644 (file)
 #include "referencecache.h"
 #include "texwindow.h"
 
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+/* workaround for gtk 2.24 issue: not displayed glwidget after toggle */
+#define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget) g_object_set_data( G_OBJECT( window ), "glwidget", G_OBJECT( widget ) )
+#else
+#define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget)
+#endif
 
 struct layout_globals_t
 {
@@ -3091,6 +3097,8 @@ void MainFrame::Create(){
                        }
                        CamWnd_setParent( *m_pCamWnd, window );
 
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( window, CamWnd_getWidget( *m_pCamWnd ) );
+
                        g_floating_windows.push_back( window );
                }
 
@@ -3110,6 +3118,8 @@ void MainFrame::Create(){
                        }
                        XY_Top_Shown_Construct( window );
 
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( window, m_pXYWnd->GetWidget() );
+
                        g_floating_windows.push_back( window );
                }
 
@@ -3129,6 +3139,8 @@ void MainFrame::Create(){
 
                        XZ_Front_Shown_Construct( window );
 
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( window, m_pXZWnd->GetWidget() );
+
                        g_floating_windows.push_back( window );
                }
 
@@ -3148,12 +3160,16 @@ void MainFrame::Create(){
 
                        YZ_Side_Shown_Construct( window );
 
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( window, m_pYZWnd->GetWidget() );
+
                        g_floating_windows.push_back( window );
                }
 
                {
                        auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
                        g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( GroupDialog_getWindow(), TextureBrowser_getGLWidget() );
                }
 
                GroupDialog_show();
@@ -3187,6 +3203,8 @@ void MainFrame::Create(){
                {
             auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
                        g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
+
+                       WORKAROUND_GOBJECT_SET_GLWIDGET( window, TextureBrowser_getGLWidget() );
                }
        }
 
index 87094456636620ff9c038cbf2d29ab9f6163a25e..fee615cfe0fc246562715feb995e3ff343b32f8e 100644 (file)
@@ -2703,3 +2703,9 @@ void TextureBrowser_Destroy(){
 
        Textures_setModeChangedNotify( Callback<void()>() );
 }
+
+#if WORKAROUND_WINDOWS_GTK2_GLWIDGET
+ui::GLArea TextureBrowser_getGLWidget(){
+       return GlobalTextureBrowser().m_gl_widget;
+}
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
index 2d5125e4b0ac59755ca9ad3a9164ef8660fc09eb..80aa5e4d0bb9a5aa41e558112e046b92ad04c815 100644 (file)
@@ -56,4 +56,8 @@ void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler );
 
 void TextureBrowser_RefreshShaders();
 
+#ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET
+ui::GLArea TextureBrowser_getGLWidget();
+#endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
+
 #endif