]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/gtkutil/window.cpp
gtk2: do not make floating windows minimizable
[xonotic/netradiant.git] / libs / gtkutil / window.cpp
index e2d7ec39a0938d54617947b2f97ca03e86bc3731..50bc6df7c1abd2fe66932df757693e9f3b965f91 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();
        }
 }
@@ -85,6 +95,19 @@ 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.
+        * Design choice: those floating windows are made to be displayed/hidden using menu or shortcuts,
+        * then the OS-specific way to minimize/restore them is superfluous and less efficient.
+        * The mainframe is not a floating window and is not created using this function so the user
+        * minimizes the application by minimizing the mainframe.
+        */
+       gtk_window_set_type_hint( window, GDK_WINDOW_TYPE_HINT_MENU );
+
        if ( parent ) {
                gtk_window_set_transient_for( window, parent );
                connect_floating_window_destroy_present( window, parent );
@@ -183,30 +206,30 @@ void window_set_position(ui::Window window, const WindowPosition &position)
        gtk_window_set_default_size( window, position.w, position.h );
 }
 
-void WindowPosition_Parse(WindowPosition &position, const char *value)
+void WindowPosition_String::Import(WindowPosition &position, const char *value)
 {
        if ( sscanf( value, "%d %d %d %d", &position.x, &position.y, &position.w, &position.h ) != 4 ) {
                position = WindowPosition( c_default_window_pos ); // ensure sane default value for window position
        }
 }
 
-void WindowPosition_Write(const WindowPosition &position, const ImportExportCallback<const char *>::Import_t &importCallback)
+void WindowPosition_String::Export(const WindowPosition &self, const Callback<void(const char *)> &returnz)
 {
        char buffer[64];
-       sprintf( buffer, "%d %d %d %d", position.x, position.y, position.w, position.h );
-       importCallback( buffer );
+       sprintf( buffer, "%d %d %d %d", self.x, self.y, self.w, self.h );
+       returnz( buffer );
 }
 
-void WindowPositionTracker_importString(WindowPositionTracker &self, const char *value)
+void WindowPositionTracker_String::Import(WindowPositionTracker &self, const char *value)
 {
        WindowPosition position;
-       WindowPosition_Parse( position, value );
+       WindowPosition_String::Import( position, value );
        self.setPosition( position );
 }
 
-void WindowPositionTracker_exportString(const WindowPositionTracker &self, const ImportExportCallback<const char *>::Import_t &importer)
+void WindowPositionTracker_String::Export(const WindowPositionTracker &self, const Callback<void(const char *)> &returnz)
 {
-       WindowPosition_Write( self.getPosition(), importer );
+       WindowPosition_String::Export( self.getPosition(), returnz );
 }
 
 gboolean WindowPositionTracker::configure(ui::Widget widget, GdkEventConfigure *event, WindowPositionTracker *self)