From: Jon A. Cruz Date: Tue, 12 Jan 2010 09:59:58 +0000 (-0800) Subject: Initial cut of disabling floating windows on window managers with problems. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=89694abbbf7ad16df214d9c2e40c28ba0bb316aa;p=inkscape.git Initial cut of disabling floating windows on window managers with problems. --- diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 2153606c1..ddc28a858 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -20,9 +20,18 @@ #include "widgets/toolbox.h" #include "widgets/desktop-widget.h" +#ifdef GDK_WINDOWING_X11 +#include +#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 desktops; static vector dtws; static map > 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::iterator it = dtws.begin(); it != dtws.end(); ++it) { diff --git a/src/ui/uxmanager.h b/src/ui/uxmanager.h index 862c675d0..aecda2b5e 100644 --- a/src/ui/uxmanager.h +++ b/src/ui/uxmanager.h @@ -41,8 +41,12 @@ public: void setTask(SPDesktop* dt, gint val); + bool isFloatWindowProblem() const; + private: UXManager(); + + bool floatwindowIssues; }; } // namespace UI diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 6655df3eb..32d682904 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -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); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 4f61d9659..6724da1bb 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -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(0)); - g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast(0)); + if ( GTK_IS_HANDLE_BOX(hb) ) { + g_signal_connect(G_OBJECT(hb), "child_detached", G_CALLBACK(handlebox_detached), static_cast(0)); + g_signal_connect(G_OBJECT(hb), "child_attached", G_CALLBACK(handlebox_attached), static_cast(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(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);