Code

Initial cut of disabling floating windows on window managers with problems.
authorJon A. Cruz <jon@joncruz.org>
Tue, 12 Jan 2010 09:59:58 +0000 (01:59 -0800)
committerJon A. Cruz <jon@joncruz.org>
Tue, 12 Jan 2010 09:59:58 +0000 (01:59 -0800)
src/ui/uxmanager.cpp
src/ui/uxmanager.h
src/widgets/desktop-widget.cpp
src/widgets/toolbox.cpp

index 2153606c1e303efa1e9a182eafb43ba4ff4cf36a..ddc28a85892d6f46af4684aeedf6332550f15e6b 100644 (file)
 #include "widgets/toolbox.h"
 #include "widgets/desktop-widget.h"
 
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif // GDK_WINDOWING_X11
+
 using std::map;
 using std::vector;
 
+
+gchar const* KDE_WINDOW_MANAGER_NAME = "KWin";
+gchar const* UNKOWN_WINDOW_MANAGER_NAME = "unknown";
+
+
 static vector<SPDesktop*> desktops;
 static vector<SPDesktopWidget*> dtws;
 static map<SPDesktop*, vector<GtkWidget*> > trackedBoxes;
@@ -43,19 +52,38 @@ UXManager* UXManager::getInstance()
 }
 
 
-UXManager::UXManager()
+UXManager::UXManager() :
+    floatwindowIssues(false)
 {
     ege::TagSet tags;
     tags.setLang("en");
 
     tags.addTag(ege::Tag("General"));
     tags.addTag(ege::Tag("Icons"));
+
+#ifdef GDK_WINDOWING_X11
+    char const* wmName = gdk_x11_screen_get_window_manager_name( gdk_screen_get_default() );
+    //g_message("Window manager is [%s]", wmName);
+
+    //if (g_ascii_strcasecmp( wmName, UNKOWN_WINDOW_MANAGER_NAME ) == 0) {
+    if (g_ascii_strcasecmp( wmName, KDE_WINDOW_MANAGER_NAME ) == 0) {
+        floatwindowIssues = true;
+    }
+#elif GDK_WINDOWING_WIN32
+    floatwindowIssues = true;
+#endif // GDK_WINDOWING_WIN32
 }
 
 UXManager::~UXManager()
 {
 }
 
+
+bool UXManager::isFloatWindowProblem() const
+{
+    return floatwindowIssues;
+}
+
 void UXManager::setTask(SPDesktop* dt, gint val)
 {
     for (vector<SPDesktopWidget*>::iterator it = dtws.begin(); it != dtws.end(); ++it) {
index 862c675d02499792f3b72e7530ecccec975ea17b..aecda2b5e7efaf68ee9b3ef63c494049f8649d91 100644 (file)
@@ -41,8 +41,12 @@ public:
 
     void setTask(SPDesktop* dt, gint val);
 
+    bool isFloatWindowProblem() const;
+
 private:
     UXManager();
+
+    bool floatwindowIssues;
 };
 
 } // namespace UI
index 6655df3ebfe7fd57cdc4d7bdd5cfdc738749b5a0..32d6829041e99a8e1293c5c4432f75c70a15d428 100644 (file)
@@ -337,6 +337,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
     gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->commands_toolbox, FALSE, TRUE, 0);
 
     dtw->tool_toolbox = ToolboxFactory::createToolToolbox();
+    ToolboxFactory::setOrientation( dtw->tool_toolbox, GTK_ORIENTATION_VERTICAL );
     gtk_box_pack_start( GTK_BOX(dtw->hbox), dtw->tool_toolbox, FALSE, TRUE, 0 );
 
     tbl = gtk_table_new (2, 3, FALSE);
index 4f61d9659a69be647d73fcdfea4e9fb83f94effa..6724da1bb575eb59dfed73df82632dcdb893cc98 100644 (file)
@@ -118,7 +118,7 @@ enum BarId {
 };
 
 #define BAR_ID_KEY "BarIdValue"
-
+#define HANDLE_POS_MARK "x-inkscape-pos"
 
 static void       sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
 static void       sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder);
@@ -895,10 +895,15 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType han
 
     gtk_widget_set_sensitive(tb, FALSE);
 
-    GtkWidget *hb = gtk_handle_box_new();
-    gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), handlePos);
-    gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
-    gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
+    GtkWidget *hb = 0;
+    if ( UXManager::getInstance()->isFloatWindowProblem() ) {
+        hb = gtk_event_box_new(); // A simple, neutral container.
+    } else {
+        hb = gtk_handle_box_new();
+        gtk_handle_box_set_handle_position(GTK_HANDLE_BOX(hb), handlePos);
+        gtk_handle_box_set_shadow_type(GTK_HANDLE_BOX(hb), GTK_SHADOW_OUT);
+        gtk_handle_box_set_snap_edge(GTK_HANDLE_BOX(hb), GTK_POS_LEFT);
+    }
 
     gtk_container_add(GTK_CONTAINER(hb), tb);
     gtk_widget_show(GTK_WIDGET(tb));
@@ -906,8 +911,10 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType han
     sigc::connection* conn = new sigc::connection;
     g_object_set_data(G_OBJECT(hb), "event_context_connection", conn);
 
-    g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
-    g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+    if ( GTK_IS_HANDLE_BOX(hb) ) {
+        g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast<gpointer>(0));
+        g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast<gpointer>(0));
+    }
 
     gpointer val = GINT_TO_POINTER(id);
     g_object_set_data(G_OBJECT(hb), BAR_ID_KEY, val);
@@ -1653,6 +1660,9 @@ static void setupToolboxCommon( GtkWidget *toolbox,
         // g_message("GRABBING ORIENTATION   [%s]", toolbarName);
         GtkPositionType pos = gtk_handle_box_get_handle_position(GTK_HANDLE_BOX(toolbox));
         orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
+    } else {
+        GtkPositionType pos = static_cast<GtkPositionType>(GPOINTER_TO_INT(g_object_get_data( G_OBJECT(toolbox), HANDLE_POS_MARK )));
+        orientation = ((pos == GTK_POS_LEFT) || (pos == GTK_POS_RIGHT)) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
     }
     gtk_toolbar_set_orientation(GTK_TOOLBAR(toolBar), orientation);
     gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolBar), TRUE);
@@ -1706,10 +1716,12 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati
                     }
                     g_list_free(children);
                 } else {
+                    // The call is being made before the toolbox proper has been setup.
                     if (GTK_IS_HANDLE_BOX(toolbox)) {
                         handleBox = GTK_HANDLE_BOX(toolbox);
+                    } else {
+                        g_object_set_data(G_OBJECT(toolbox), HANDLE_POS_MARK, GINT_TO_POINTER(pos));
                     }
-                    // The call is being made before the toolbox proper has been setup.
                 }
             } else if (GTK_IS_TOOLBAR(child)) {
                 GtkToolbar* toolbar = GTK_TOOLBAR(child);