]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/gtkutil/window.cpp
Merge commit 'e984b9f54a0c733aab34a8ec19724dc4114ade28' into master-merge
[xonotic/netradiant.git] / libs / gtkutil / window.cpp
index 4c4536605fe799bcb6687b5c8b186b4137b98173..c8671a2fbcf0ab25976c5658d26a02d6abf87e44 100644 (file)
@@ -39,6 +39,15 @@ inline void CHECK_RESTORE( ui::Widget w ){
 #endif // WORKAROUND_WINDOWS_GTK2_GLWIDGET
 
                w.show();
+#define GARUX_GTK_WORKAROUND
+#ifndef GARUX_GTK_WORKAROUND
+               /* workaround for gtk 2.24 issue: not displayed glwidget after min/restore */
+               GtkWidget* glwidget = GTK_WIDGET( g_object_get_data( G_OBJECT( w ), "glwidget" ) );
+               if ( glwidget ){
+                       gtk_widget_hide( glwidget );
+                       gtk_widget_show( glwidget );
+               }
+#endif
        }
 }
 
@@ -95,11 +104,47 @@ ui::Window create_floating_window( const char* title, ui::Window parent ){
        ui::Window window = ui::Window( ui::window_type::TOP );
        gtk_window_set_title( window, title );
 
+       /* Workaround: Windows minimizes the whole application including all the floating windows when
+        * one floating windows is minimized, this leads to an infinite loop of minimize/restore events,
+        * probably because of some race condition betwen all floating windows not having the same state
+        * at the same time, some being minimized while being restored at the same time, triggering the
+        * minimization and the restoration of the others, and so on.
+        * It's difficult to say such bug will never happen on other OS or with some window manager.
+        * While it's possible to decide this can be a design choihce since those floating windows are made
+        * to be displayed/hidden using menu or shortcuts, meaning the OS-specific way to minimize/restore
+        * them is superfluous and less efficient, the floating window mode that fixes issues on Windows
+        * is also known to be broken on KDE (the floating window does not get focus), this is likely to be
+        * a bug in kwin.
+        * In any way the mainframe is not a floating window and is not created using this function so the
+        * user minimizes the whole application including floating windows by minimizing the mainframe
+        */
+
+#ifdef WORKAROUND_WINDOWS_FLOATING_WINDOW
+       gtk_window_set_type_hint( window, GDK_WINDOW_TYPE_HINT_UTILITY );
+#endif // WORKAROUND_WINDOWS_FLOATING_WINDOW
+
        if ( parent ) {
                gtk_window_set_transient_for( window, parent );
                connect_floating_window_destroy_present( window, parent );
                g_object_set_data( G_OBJECT( window ), "floating_handler", gint_to_pointer( connect_floating( parent, window ) ) );
                window.connect( "destroy", G_CALLBACK( destroy_disconnect_floating ), parent );
+/*
+               //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_UTILITY);
+               //gtk_window_set_type_hint (window,GDK_WINDOW_TYPE_HINT_DIALOG);
+               gtk_window_set_keep_above ( window, TRUE );
+               GtkWidget* widget = GTK_WIDGET( window );
+               gtk_widget_realize ( widget );
+               GdkWindow* gdk_window = gtk_widget_get_window( widget );
+               //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)(GDK_DECOR_BORDER|GDK_DECOR_RESIZEH|GDK_DECOR_TITLE|GDK_DECOR_MENU|GDK_DECOR_MINIMIZE|GDK_DECOR_MAXIMIZE) );
+               //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_RESIZE|GDK_FUNC_MOVE|GDK_FUNC_MINIMIZE|GDK_FUNC_MAXIMIZE|GDK_FUNC_CLOSE ) );
+               //gdk_window_set_decorations ( gdk_window, (GdkWMDecoration)( GDK_DECOR_ALL ) );
+               //gdk_window_set_functions ( gdk_window, (GdkWMFunction)( GDK_FUNC_ALL ) );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_DIALOG );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_UTILITY );
+               //gdk_window_set_type_hint ( gdk_window, GDK_WINDOW_TYPE_HINT_NORMAL );
+               gdk_window_set_skip_taskbar_hint ( gdk_window, TRUE );
+               gdk_window_set_skip_pager_hint ( gdk_window, TRUE );
+*/
        }
 
        return window;