diff options
48 files changed, 970 insertions, 1545 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d5b4c3357..11a7ea796 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,19 @@ set (CMAKE_CXX_FLAGS "-DGNOME_DESKTOP_USE_UNSTABLE_API -std=c++0x -fno-permissiv set (CMAKE_CXX_FLAGS_DEBUG "-g3") set (CMAKE_CXX_FLAGS_RELEASE "") +option( + UNITY_ENABLE_X_ORG_SUPPORT + "Enable X.org support in unity" + ON +) + +if(UNITY_ENABLE_X_ORG_SUPPORT) + add_definitions(-DUNITY_HAS_X_ORG_SUPPORT) + message("Unity is configured with support for X.org") +else () + message("Unity is configured with without X.org") +endif() + if (BUILD_GLES) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNUX_OPENGLES_20 -DUSE_GLES") set (UNITY_STANDALONE_LADD "-lunity-core-${UNITY_API_VERSION} -lm -lpthread -ldl") diff --git a/dash/DashController.cpp b/dash/DashController.cpp index 0e4459ee1..38faea260 100644 --- a/dash/DashController.cpp +++ b/dash/DashController.cpp @@ -1,5 +1,6 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -22,12 +23,13 @@ #include <Nux/HLayout.h> #include <UnityCore/GLibWrapper.h> -#include "unity-shared/UnitySettings.h" -#include "unity-shared/PanelStyle.h" #include "unity-shared/DashStyle.h" -#include "unity-shared/PluginAdapter.h" +#include "unity-shared/PanelStyle.h" #include "unity-shared/UBusMessages.h" +#include "unity-shared/UnitySettings.h" #include "unity-shared/UScreen.h" +#include "unity-shared/WindowManager.h" + namespace unity { @@ -89,7 +91,7 @@ Controller::Controller() }); auto spread_cb = sigc::bind(sigc::mem_fun(this, &Controller::HideDash), true); - PluginAdapter::Default()->initiate_spread.connect(spread_cb); + WindowManager::Default().initiate_spread.connect(spread_cb); g_bus_get (G_BUS_TYPE_SESSION, dbus_connect_cancellable_, OnBusAcquired, this); } @@ -114,11 +116,11 @@ void Controller::SetupWindow() window_->mouse_down_outside_pointer_grab_area.connect(sigc::mem_fun(this, &Controller::OnMouseDownOutsideWindow)); /* FIXME - first time we load our windows there is a race that causes the input window not to actually get input, this side steps that by causing an input window show and hide before we really need it. */ - auto plugin_adapter = PluginAdapter::Default(); - plugin_adapter->saveInputFocus (); + WindowManager& wm = WindowManager::Default(); + wm.SaveInputFocus (); window_->EnableInputWindow(true, dash::window_title, true, false); window_->EnableInputWindow(false, dash::window_title, true, false); - plugin_adapter->restoreInputFocus (); + wm.RestoreInputFocus (); } void Controller::SetupDashView() @@ -276,18 +278,18 @@ void Controller::OnExternalHideDash(GVariant* variant) void Controller::ShowDash() { EnsureDash(); - PluginAdapter* adaptor = PluginAdapter::Default(); + WindowManager& wm = WindowManager::Default(); // Don't want to show at the wrong time - if (visible_ || adaptor->IsExpoActive() || adaptor->IsScaleActive()) + if (visible_ || wm.IsExpoActive() || wm.IsScaleActive()) return; // We often need to wait for the mouse/keyboard to be available while a plugin // is finishing it's animations/cleaning up. In these cases, we patiently wait // for the screen to be available again before honouring the request. - if (adaptor->IsScreenGrabbed()) + if (wm.IsScreenGrabbed()) { screen_ungrabbed_slot_.disconnect(); - screen_ungrabbed_slot_ = PluginAdapter::Default()->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); + screen_ungrabbed_slot_ = wm.screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); need_show_ = true; return; } @@ -337,7 +339,7 @@ void Controller::HideDash(bool restore) nux::GetWindowCompositor().SetKeyFocusArea(NULL,nux::KEY_NAV_NONE); if (restore) - PluginAdapter::Default ()->restoreInputFocus (); + WindowManager::Default().RestoreInputFocus(); StartShowHideTimeline(); @@ -376,8 +378,9 @@ gboolean Controller::CheckShortcutActivation(const char* key_string) std::string lens_id = view_->GetIdForShortcutActivation(std::string(key_string)); if (lens_id != "") { - if (PluginAdapter::Default()->IsScaleActive()) - PluginAdapter::Default()->TerminateScale(); + WindowManager& wm = WindowManager::Default(); + if (wm.IsScaleActive()) + wm.TerminateScale(); GVariant* args = g_variant_new("(sus)", lens_id.c_str(), dash::GOTO_DASH_URI, ""); OnActivateRequest(args); diff --git a/hud/HudController.cpp b/hud/HudController.cpp index 0ae81222a..6f68f9dc5 100644 --- a/hud/HudController.cpp +++ b/hud/HudController.cpp @@ -75,9 +75,9 @@ Controller::Controller(std::function<AbstractView*(void)> const& function) launcher_width.changed.connect([&] (int new_width) { Relayout(); }); - auto wm = WindowManager::Default(); - wm->compiz_screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); - wm->initiate_spread.connect(sigc::bind(sigc::mem_fun(this, &Controller::HideHud), true)); + WindowManager& wm = WindowManager::Default(); + wm.screen_ungrabbed.connect(sigc::mem_fun(this, &Controller::OnScreenUngrabbed)); + wm.initiate_spread.connect(sigc::bind(sigc::mem_fun(this, &Controller::HideHud), true)); hud_service_.queries_updated.connect(sigc::mem_fun(this, &Controller::OnQueriesFinished)); timeline_animator_.animation_updated.connect(sigc::mem_fun(this, &Controller::OnViewShowHideFrame)); @@ -106,11 +106,11 @@ void Controller::SetupWindow() /* FIXME - first time we load our windows there is a race that causes the * input window not to actually get input, this side steps that by causing * an input window show and hide before we really need it. */ - auto wm = WindowManager::Default(); - wm->saveInputFocus (); + WindowManager& wm = WindowManager::Default(); + wm.SaveInputFocus(); window_->EnableInputWindow(true, "Hud", true, false); window_->EnableInputWindow(false, "Hud", true, false); - wm->restoreInputFocus (); + wm.RestoreInputFocus(); } void Controller::SetupHudView() @@ -293,14 +293,14 @@ bool Controller::IsVisible() void Controller::ShowHud() { - WindowManager* adaptor = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); LOG_DEBUG(logger) << "Showing the hud"; EnsureHud(); - if (visible_ || adaptor->IsExpoActive() || adaptor->IsScaleActive()) + if (visible_ || wm.IsExpoActive() || wm.IsScaleActive()) return; - if (adaptor->IsScreenGrabbed()) + if (wm.IsScreenGrabbed()) { need_show_ = true; return; @@ -344,8 +344,8 @@ void Controller::ShowHud() Window xid = bamf_window_get_xid(win); if (bamf_view_user_visible(view) && bamf_window_get_window_type(win) != BAMF_WINDOW_DOCK && - WindowManager::Default()->IsWindowOnCurrentDesktop(xid) && - WindowManager::Default()->IsWindowVisible(xid) && + wm.IsWindowOnCurrentDesktop(xid) && + wm.IsWindowVisible(xid) && std::find(unity_xids.begin(), unity_xids.end(), xid) == unity_xids.end()) { active_win = win; @@ -416,7 +416,7 @@ void Controller::HideHud(bool restore) restore = true; if (restore) - WindowManager::Default ()->restoreInputFocus (); + WindowManager::Default().RestoreInputFocus(); hud_service_.CloseQuery(); diff --git a/launcher/AbstractLauncherIcon.h b/launcher/AbstractLauncherIcon.h index d95e78f30..ab3197bc3 100644 --- a/launcher/AbstractLauncherIcon.h +++ b/launcher/AbstractLauncherIcon.h @@ -26,15 +26,13 @@ #include <NuxCore/Math/MathInc.h> #include <sigc++/sigc++.h> - -#include <X11/Xlib.h> - #include <libdbusmenu-glib/menuitem.h> #include "DndData.h" #include "unity-shared/Introspectable.h" #include "LauncherEntryRemote.h" #include "unity-shared/IconTextureSource.h" +#include "unity-shared/WindowManager.h" namespace unity { diff --git a/launcher/BamfLauncherIcon.cpp b/launcher/BamfLauncherIcon.cpp index 3ca7532ed..b51018810 100644 --- a/launcher/BamfLauncherIcon.cpp +++ b/launcher/BamfLauncherIcon.cpp @@ -32,7 +32,6 @@ #include "FavoriteStore.h" #include "Launcher.h" #include "MultiMonitor.h" -#include "unity-shared/WindowManager.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/ubus-server.h" @@ -149,10 +148,11 @@ BamfLauncherIcon::BamfLauncherIcon(BamfApplication* app) }); _gsignals.Add(sig); - WindowManager::Default()->window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized)); - WindowManager::Default()->window_moved.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMoved)); - WindowManager::Default()->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); - WindowManager::Default()->terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); + WindowManager& wm = WindowManager::Default(); + wm.window_minimized.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMinimized)); + wm.window_moved.connect(sigc::mem_fun(this, &BamfLauncherIcon::OnWindowMoved)); + wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); + wm.terminate_expo.connect(sigc::mem_fun(this, &BamfLauncherIcon::EnsureWindowState)); EnsureWindowState(); UpdateMenus(); @@ -214,15 +214,15 @@ bool BamfLauncherIcon::IsUrgent() const void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) { SimpleLauncherIcon::ActivateLauncherIcon(arg); - WindowManager* wm = WindowManager::Default(); - bool scaleWasActive = wm->IsScaleActive(); + WindowManager& wm = WindowManager::Default(); + bool scaleWasActive = wm.IsScaleActive(); bool active = IsActive(); bool user_visible = IsRunning(); if (arg.target && OwnsWindow(arg.target)) { - wm->Activate(arg.target); + wm.Activate(arg.target); return; } @@ -258,23 +258,23 @@ void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) continue; - if (!any_visible && wm->IsWindowOnCurrentDesktop(xid)) + if (!any_visible && wm.IsWindowOnCurrentDesktop(xid)) { any_visible = true; } - if (!any_mapped && wm->IsWindowMapped(xid)) + if (!any_mapped && wm.IsWindowMapped(xid)) { any_mapped = true; } - if (!any_on_top && wm->IsWindowOnTop(xid)) + if (!any_on_top && wm.IsWindowOnTop(xid)) { any_on_top = true; } if (!any_on_monitor && bamf_window_get_monitor(win) == arg.monitor && - wm->IsWindowMapped(xid) && wm->IsWindowVisible(xid)) + wm.IsWindowMapped(xid) && wm.IsWindowVisible(xid)) { any_on_monitor = true; } @@ -310,7 +310,7 @@ void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) if (scaleWasActive) { - wm->TerminateScale(); + wm.TerminateScale(); } SetQuirk(Quirk::STARTING, true); @@ -322,7 +322,7 @@ void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) { if (scaleWasActive) // #5 above { - wm->TerminateScale(); + wm.TerminateScale(); Focus(arg); } else // #2 above @@ -337,7 +337,7 @@ void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) { if (scaleWasActive) // #4 above { - wm->TerminateScale(); + wm.TerminateScale(); Focus(arg); if (arg.source != ActionArg::SWITCHER) Spread(true, 0, false); @@ -352,7 +352,7 @@ void BamfLauncherIcon::ActivateLauncherIcon(ActionArg arg) std::vector<Window> BamfLauncherIcon::GetWindows(WindowFilterMask filter, int monitor) { - WindowManager* wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); std::vector<Window> results; if (!BAMF_IS_VIEW(_bamf_app.RawPtr())) @@ -384,9 +384,9 @@ std::vector<Window> BamfLauncherIcon::GetWindows(WindowFilterMask filter, int mo { guint32 xid = bamf_window_get_xid(window); - if ((mapped && wm->IsWindowMapped(xid)) || !mapped) + if ((mapped && wm.IsWindowMapped(xid)) || !mapped) { - if ((current_desktop && wm->IsWindowOnCurrentDesktop(xid)) || !current_desktop) + if ((current_desktop && wm.IsWindowOnCurrentDesktop(xid)) || !current_desktop) { results.push_back(xid); } @@ -621,7 +621,7 @@ void BamfLauncherIcon::OpenInstanceLauncherIcon(ActionArg arg) std::vector<Window> BamfLauncherIcon::GetFocusableWindows(ActionArg arg, bool &any_visible, bool &any_urgent) { bool any_user_visible = false; - WindowManager* wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); std::vector<Window> windows; GList* children; @@ -696,7 +696,7 @@ std::vector<Window> BamfLauncherIcon::GetFocusableWindows(ActionArg arg, bool &a windows.push_back(xid); } - if (wm->IsWindowOnCurrentDesktop(xid) && wm->IsWindowVisible(xid)) + if (wm.IsWindowOnCurrentDesktop(xid) && wm.IsWindowVisible(xid)) { any_visible = true; } @@ -711,7 +711,6 @@ std::vector<Window> BamfLauncherIcon::GetFocusableWindows(ActionArg arg, bool &a void BamfLauncherIcon::Focus(ActionArg arg) { bool any_visible = false, any_urgent = false; - WindowManager* wm = WindowManager::Default(); std::vector<Window> windows = GetFocusableWindows(arg, any_visible, any_urgent); auto visibility = WindowManager::FocusVisibility::OnlyVisible; @@ -729,13 +728,13 @@ void BamfLauncherIcon::Focus(ActionArg arg) } bool only_top_win = !any_urgent; - wm->FocusWindowGroup(windows, visibility, arg.monitor, only_top_win); + WindowManager::Default().FocusWindowGroup(windows, visibility, arg.monitor, only_top_win); } bool BamfLauncherIcon::Spread(bool current_desktop, int state, bool force) { auto windows = GetWindows(current_desktop ? WindowFilter::ON_CURRENT_DESKTOP : 0); - return WindowManager::Default()->ScaleWindowGroup(windows, state, force); + return WindowManager::Default().ScaleWindowGroup(windows, state, force); } void BamfLauncherIcon::EnsureWindowState() @@ -755,7 +754,7 @@ void BamfLauncherIcon::EnsureWindowState() /* BamfTab does not support the monitor interface...so a bit of a nasty hack here. */ xid = bamf_tab_get_xid (static_cast<BamfTab*>(l->data)); - if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid) == false) + if (WindowManager::Default().IsWindowOnCurrentDesktop(xid) == false) continue; for (int j = 0; j < max_num_monitors; j++) @@ -771,7 +770,7 @@ void BamfLauncherIcon::EnsureWindowState() xid = bamf_window_get_xid(window); int monitor = bamf_window_get_monitor(window); - if (monitor >= 0 && WindowManager::Default()->IsWindowOnCurrentDesktop(xid)) + if (monitor >= 0 && WindowManager::Default().IsWindowOnCurrentDesktop(xid)) monitors[monitor] = true; } @@ -923,7 +922,7 @@ void BamfLauncherIcon::Quit() continue; Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data)); - WindowManager::Default()->Close(xid); + WindowManager::Default().Close(xid); } g_list_free(children); @@ -1195,7 +1194,7 @@ void BamfLauncherIcon::UpdateIconGeometries(std::vector<nux::Point3> center) geo.x = center[monitor].x - 24; geo.y = center[monitor].y - 24; - WindowManager::Default()->SetWindowIconGeometry(xid, geo); + WindowManager::Default().SetWindowIconGeometry(xid, geo); } g_list_free(children); @@ -1338,7 +1337,7 @@ unsigned long long BamfLauncherIcon::SwitcherPriority() continue; Window xid = bamf_window_get_xid(static_cast<BamfWindow*>(l->data)); - result = std::max(result, WindowManager::Default()->GetWindowActiveNumber(xid)); + result = std::max(result, WindowManager::Default().GetWindowActiveNumber(xid)); } g_list_free(children); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 1af7c74e6..21af1b0b3 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -97,8 +97,8 @@ add_dependencies (switcher-lib unity-core-${UNITY_API_VERSION} unity-shared) # add_executable (launcher StandaloneLauncher.cpp) add_dependencies (launcher launcher-lib) -target_link_libraries (launcher launcher-lib unity-shared) +target_link_libraries (launcher launcher-lib unity-shared unity-shared-standalone) add_executable (switcher StandaloneSwitcher.cpp) add_dependencies (switcher switcher-lib launcher-lib) -target_link_libraries (switcher switcher-lib launcher-lib unity-shared) +target_link_libraries (switcher switcher-lib launcher-lib unity-shared unity-shared-standalone) diff --git a/launcher/DNDCollectionWindow.cpp b/launcher/DNDCollectionWindow.cpp index 6925c779e..6b0dac695 100644 --- a/launcher/DNDCollectionWindow.cpp +++ b/launcher/DNDCollectionWindow.cpp @@ -18,10 +18,11 @@ */ #include "DNDCollectionWindow.h" + #include "unity-shared/WindowManager.h" namespace unity { - + NUX_IMPLEMENT_OBJECT_TYPE(DNDCollectionWindow); DNDCollectionWindow::DNDCollectionWindow() @@ -32,16 +33,17 @@ DNDCollectionWindow::DNDCollectionWindow() SetBackgroundColor(nux::Color(0x00000000)); SetOpacity(0.0f); // ... and as big as the whole screen. - SetGeometry(WindowManager::Default()->GetScreenGeometry()); - + WindowManager& wm = WindowManager::Default(); + SetGeometry(wm.GetScreenGeometry()); + ShowWindow(true); PushToBack(); // Hack to create the X Window as soon as possible. EnableInputWindow(true, "DNDCollectionWindow"); EnableInputWindow(false, "DNDCollectionWindow"); SetDndEnabled(false, true); - - WindowManager::Default()->window_moved.connect(sigc::mem_fun(this, &DNDCollectionWindow::OnWindowMoved)); + + wm.window_moved.connect(sigc::mem_fun(this, &DNDCollectionWindow::OnWindowMoved)); } DNDCollectionWindow::~DNDCollectionWindow() @@ -51,14 +53,14 @@ DNDCollectionWindow::~DNDCollectionWindow() } /** - * EnableInputWindow doesn't show the window immediately. + * EnableInputWindow doesn't show the window immediately. * Since nux::EnableInputWindow uses XMoveResizeWindow the best way to know if * the X Window is really on/off screen is receiving WindowManager::window_moved * signal. Please don't hate me! - **/ -void DNDCollectionWindow::OnWindowMoved(guint32 xid) + **/ +void DNDCollectionWindow::OnWindowMoved(Window window_id) { - if (xid == GetInputWindowId() && display() != NULL) + if (window_id == GetInputWindowId() && display() != NULL) { // Create a fake mouse move because sometimes an extra one is required. XWarpPointer(display(), None, None, 0, 0, 0, 0, 0, 0); diff --git a/launcher/DNDCollectionWindow.h b/launcher/DNDCollectionWindow.h index c52d5e9d7..a899d3cde 100644 --- a/launcher/DNDCollectionWindow.h +++ b/launcher/DNDCollectionWindow.h @@ -30,9 +30,9 @@ namespace unity { /** * DNDCollectionWindow makes it possible to collect drag and drop (dnd) data as - * soon as dnd starts and not when the mouse pointer enter the x window. + * soon as dnd starts and not when the mouse pointer enter the x window. **/ - + class DNDCollectionWindow : public nux::BaseWindow { NUX_DECLARE_OBJECT_TYPE(DNDCollectionWindow, nux::BaseWindow); @@ -41,23 +41,23 @@ NUX_DECLARE_OBJECT_TYPE(DNDCollectionWindow, nux::BaseWindow); public: DNDCollectionWindow(); ~DNDCollectionWindow(); - + void Collect(); - + private: void ProcessDndMove(int x, int y, std::list<char*> mimes); - void OnWindowMoved(guint32 xid); + void OnWindowMoved(Window window_id); // Members public: nux::Property<Display*> display; sigc::signal<void, const std::list<char*>&> collected; - + private: std::list<char*> mimes_; }; - + } // namespace unity #endif // DNDCOLLECTIONWINDOW_H diff --git a/launcher/DesktopLauncherIcon.cpp b/launcher/DesktopLauncherIcon.cpp index 50ec49624..9b70bf579 100644 --- a/launcher/DesktopLauncherIcon.cpp +++ b/launcher/DesktopLauncherIcon.cpp @@ -39,11 +39,10 @@ DesktopLauncherIcon::DesktopLauncherIcon() SetShortcut('d'); } -void -DesktopLauncherIcon::ActivateLauncherIcon(ActionArg arg) +void DesktopLauncherIcon::ActivateLauncherIcon(ActionArg arg) { SimpleLauncherIcon::ActivateLauncherIcon(arg); - WindowManager::Default()->ShowDesktop(); + WindowManager::Default().ShowDesktop(); } std::string DesktopLauncherIcon::GetName() const diff --git a/launcher/ExpoLauncherIcon.cpp b/launcher/ExpoLauncherIcon.cpp index 341726e37..098ca1b27 100644 --- a/launcher/ExpoLauncherIcon.cpp +++ b/launcher/ExpoLauncherIcon.cpp @@ -18,7 +18,6 @@ */ #include "ExpoLauncherIcon.h" -#include "unity-shared/WindowManager.h" #include "FavoriteStore.h" #include <glib/gi18n-lib.h> @@ -41,23 +40,22 @@ ExpoLauncherIcon::ExpoLauncherIcon() void ExpoLauncherIcon::ActivateLauncherIcon(ActionArg arg) { SimpleLauncherIcon::ActivateLauncherIcon(arg); + WindowManager& wm = WindowManager::Default(); - auto wm = WindowManager::Default(); - - if (!wm->IsExpoActive()) + if (!wm.IsExpoActive()) { - wm->InitiateExpo(); + wm.InitiateExpo(); } else { - wm->TerminateExpo(); + wm.TerminateExpo(); } } void ExpoLauncherIcon::Stick(bool save) { SimpleLauncherIcon::Stick(save); - SetQuirk(Quirk::VISIBLE, (WindowManager::Default()->WorkspaceCount() > 1)); + SetQuirk(Quirk::VISIBLE, (WindowManager::Default().WorkspaceCount() > 1)); } std::string ExpoLauncherIcon::GetName() const diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index ff333697b..1eac17fcd 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -47,7 +47,6 @@ #include "unity-shared/TimeUtil.h" #include "unity-shared/TextureCache.h" #include "unity-shared/IconLoader.h" -#include "unity-shared/WindowManager.h" #include "unity-shared/UScreen.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UnitySettings.h" @@ -180,14 +179,14 @@ Launcher::Launcher(nux::BaseWindow* parent, ql_manager.quicklist_opened.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistOpened)); ql_manager.quicklist_closed.connect(sigc::mem_fun(this, &Launcher::RecvQuicklistClosed)); - WindowManager& plugin_adapter = *(WindowManager::Default()); - plugin_adapter.window_mapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup))); - plugin_adapter.window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup))); - plugin_adapter.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); - plugin_adapter.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); - plugin_adapter.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); - plugin_adapter.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); - plugin_adapter.compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::EnsureAnimation)); + WindowManager& wm = WindowManager::Default(); + wm.window_mapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup))); + wm.window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &Launcher::DndTimeoutSetup))); + wm.initiate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); + wm.initiate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); + wm.terminate_spread.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); + wm.terminate_expo.connect(sigc::mem_fun(this, &Launcher::OnPluginStateChanged)); + wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &Launcher::EnsureAnimation)); display.changed.connect(sigc::mem_fun(this, &Launcher::OnDisplayChanged)); @@ -1403,8 +1402,9 @@ void Launcher::DndTimeoutSetup() void Launcher::OnPluginStateChanged() { - _hide_machine.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, WindowManager::Default()->IsExpoActive()); - _hide_machine.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, WindowManager::Default()->IsScaleActive()); + WindowManager& wm = WindowManager::Default(); + _hide_machine.SetQuirk(LauncherHideMachine::EXPO_ACTIVE, wm.IsExpoActive()); + _hide_machine.SetQuirk(LauncherHideMachine::SCALE_ACTIVE, wm.IsScaleActive()); } LauncherHideMode Launcher::GetHideMode() const diff --git a/launcher/LauncherController.cpp b/launcher/LauncherController.cpp index 4c288ff9e..837f6ba7c 100644 --- a/launcher/LauncherController.cpp +++ b/launcher/LauncherController.cpp @@ -38,7 +38,6 @@ #include "LauncherControllerPrivate.h" #include "SoftwareCenterLauncherIcon.h" #include "ExpoLauncherIcon.h" -#include "unity-shared/WindowManager.h" #include "TrashLauncherIcon.h" #include "BFBLauncherIcon.h" #include "unity-shared/UScreen.h" @@ -141,8 +140,8 @@ Controller::Impl::Impl(Controller* parent) uscreen->changed.connect(sigc::mem_fun(this, &Controller::Impl::OnScreenChanged)); - WindowManager& plugin_adapter = *(WindowManager::Default()); - plugin_adapter.window_focus_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnWindowFocusChanged)); + WindowManager& wm = WindowManager::Default(); + wm.window_focus_changed.connect(sigc::mem_fun(this, &Controller::Impl::OnWindowFocusChanged)); ubus.RegisterInterest(UBUS_QUICKLIST_END_KEY_NAV, [&](GVariant * args) { if (reactivate_keynav) diff --git a/launcher/LauncherDragWindow.cpp b/launcher/LauncherDragWindow.cpp index 8fcc92ed6..6501eeb3d 100644 --- a/launcher/LauncherDragWindow.cpp +++ b/launcher/LauncherDragWindow.cpp @@ -52,9 +52,9 @@ LauncherDragWindow::LauncherDragWindow(nux::ObjectPtr<nux::IOpenGLBaseTexture> i CancelDrag(); }); - auto wm = WindowManager::Default(); - wm->window_mapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag))); - wm->window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag))); + WindowManager& wm = WindowManager::Default(); + wm.window_mapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag))); + wm.window_unmapped.connect(sigc::hide(sigc::mem_fun(this, &LauncherDragWindow::CancelDrag))); } LauncherDragWindow::~LauncherDragWindow() diff --git a/launcher/LauncherIcon.cpp b/launcher/LauncherIcon.cpp index b05cbf06d..3188654c2 100644 --- a/launcher/LauncherIcon.cpp +++ b/launcher/LauncherIcon.cpp @@ -43,7 +43,6 @@ #include "QuicklistMenuItemRadio.h" #include "MultiMonitor.h" -#include "unity-shared/WindowManager.h" #include "unity-shared/ubus-server.h" #include "unity-shared/UBusMessages.h" @@ -220,8 +219,9 @@ LauncherIcon::Activate(ActionArg arg) { /* Launcher Icons that handle spread will adjust the spread state * accordingly, for all other icons we should terminate spread */ - if (WindowManager::Default()->IsScaleActive() && !HandlesSpread ()) - WindowManager::Default()->TerminateScale(); + WindowManager& wm = WindowManager::Default(); + if (wm.IsScaleActive() && !HandlesSpread ()) + wm.TerminateScale(); ActivateLauncherIcon(arg); @@ -231,8 +231,9 @@ LauncherIcon::Activate(ActionArg arg) void LauncherIcon::OpenInstance(ActionArg arg) { - if (WindowManager::Default()->IsScaleActive()) - WindowManager::Default()->TerminateScale(); + WindowManager& wm = WindowManager::Default(); + if (wm.IsScaleActive()) + wm.TerminateScale(); OpenInstanceLauncherIcon(arg); @@ -612,16 +613,16 @@ bool LauncherIcon::OpenQuicklist(bool select_first_item, int monitor) int tip_x = geo.x + geo.width - 4 * geo.width / 48; int tip_y = _center[monitor].y; - auto win_manager = WindowManager::Default(); + WindowManager& win_manager = WindowManager::Default(); - if (win_manager->IsScaleActive()) - win_manager->TerminateScale(); + if (win_manager.IsScaleActive()) + win_manager.TerminateScale(); /* If the expo plugin is active, we need to wait it to be termated, before * shwing the icon quicklist. */ - if (win_manager->IsExpoActive()) + if (win_manager.IsExpoActive()) { - on_expo_terminated_connection = win_manager->terminate_expo.connect([&, tip_x, tip_y]() { + on_expo_terminated_connection = win_manager.terminate_expo.connect([&, tip_x, tip_y]() { QuicklistManager::Default()->ShowQuicklist(_quicklist.GetPointer(), tip_x, tip_y); on_expo_terminated_connection.disconnect(); }); diff --git a/launcher/LayoutSystem.cpp b/launcher/LayoutSystem.cpp index aa772b50d..12273038f 100644 --- a/launcher/LayoutSystem.cpp +++ b/launcher/LayoutSystem.cpp @@ -18,11 +18,10 @@ */ #include "LayoutSystem.h" -#include "unity-shared/WindowManager.h" namespace unity { namespace ui { - + LayoutSystem::LayoutSystem() { spacing = 8; @@ -33,23 +32,26 @@ LayoutSystem::~LayoutSystem() { } -void LayoutSystem::LayoutWindows (LayoutWindowList windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds) +void LayoutSystem::LayoutWindows(LayoutWindowList windows, + nux::Geometry const& max_bounds, + nux::Geometry& final_bounds) { unsigned int size = windows.size(); if (size == 0) return; - + + WindowManager& wm = WindowManager::Default(); for (auto window : windows) { - window->geo = WindowManager::Default ()->GetWindowGeometry (window->xid); + window->geo = wm.GetWindowGeometry(window->xid); window->aspect_ratio = (float)window->geo.width / (float)window->geo.height; } - - LayoutGridWindows (windows, max_bounds, final_bounds); + + LayoutGridWindows(windows, max_bounds, final_bounds); } -nux::Size LayoutSystem::GridSizeForWindows (LayoutWindowList windows, nux::Geometry const& max_bounds) +nux::Size LayoutSystem::GridSizeForWindows(LayoutWindowList windows, nux::Geometry const& max_bounds) { int count = (int)windows.size(); @@ -58,7 +60,7 @@ nux::Size LayoutSystem::GridSizeForWindows (LayoutWindowList windows, nux::Geome if (count == 2) { - float stacked_aspect = std::max (windows[0]->geo.width, windows[1]->geo.width) / (float)(windows[0]->geo.height + windows[1]->geo.height); + float stacked_aspect = std::max (windows[0]->geo.width, windows[1]->geo.width) / (float)(windows[0]->geo.height + windows[1]->geo.height); float row_aspect = (float)(windows[0]->geo.width + windows[1]->geo.width) / std::max(windows[0]->geo.height, windows[1]->geo.height); float box_aspect = (float)max_bounds.width / max_bounds.height; if (abs(row_aspect - box_aspect) > abs(stacked_aspect - box_aspect)) @@ -278,4 +280,4 @@ LayoutWindow::LayoutWindow(Window xid) } } -} \ No newline at end of file +} diff --git a/launcher/LayoutSystem.h b/launcher/LayoutSystem.h index b8bb8dfe9..f35fea473 100644 --- a/launcher/LayoutSystem.h +++ b/launcher/LayoutSystem.h @@ -22,11 +22,10 @@ #include <boost/shared_ptr.hpp> #include <sigc++/sigc++.h> - -#include <X11/Xlib.h> - #include <Nux/Nux.h> +#include "unity-shared/WindowManager.h" + namespace unity { namespace ui { @@ -36,7 +35,7 @@ public: typedef boost::shared_ptr<LayoutWindow> Ptr; LayoutWindow (Window xid); - + Window xid; nux::Geometry geo; diff --git a/launcher/SimpleLauncherIcon.cpp b/launcher/SimpleLauncherIcon.cpp index a3c6ccac4..3102388d6 100644 --- a/launcher/SimpleLauncherIcon.cpp +++ b/launcher/SimpleLauncherIcon.cpp @@ -26,7 +26,6 @@ #include <UnityCore/Variant.h> #include "SimpleLauncherIcon.h" -#include "unity-shared/PluginAdapter.h" #include "unity-shared/ubus-server.h" #include "unity-shared/UBusMessages.h" diff --git a/launcher/SwitcherController.cpp b/launcher/SwitcherController.cpp index 6202cb20d..30bc80051 100644 --- a/launcher/SwitcherController.cpp +++ b/launcher/SwitcherController.cpp @@ -74,7 +74,7 @@ bool Controller::CanShowSwitcher(const std::vector<AbstractLauncherIcon::Ptr>& r { bool empty = (show_desktop_disabled_ ? results.empty() : results.size() == 1); - return (!empty && !WindowManager::Default()->IsWallActive()); + return (!empty && !WindowManager::Default().IsWallActive()); } void Controller::Show(ShowMode show, SortMode sort, std::vector<AbstractLauncherIcon::Ptr> results) @@ -462,9 +462,10 @@ void Controller::SelectFirstItem() unsigned int first_second = 0; // first icons second highest active unsigned int second_first = 0; // second icons first highest active + WindowManager& wm = WindowManager::Default(); for (guint32 xid : first->Windows()) { - unsigned int num = WindowManager::Default()->GetWindowActiveNumber(xid); + unsigned int num = wm.GetWindowActiveNumber(xid); if (num > first_highest) { @@ -479,13 +480,13 @@ void Controller::SelectFirstItem() for (guint32 xid : second->Windows()) { - second_first = MAX (WindowManager::Default()->GetWindowActiveNumber(xid), second_first); + second_first = std::max<unsigned long long>(wm.GetWindowActiveNumber(xid), second_first); } if (first_second > second_first) - model_->Select (first); + model_->Select(first); else - model_->Select (second); + model_->Select(second); } /* Introspection */ diff --git a/launcher/SwitcherModel.cpp b/launcher/SwitcherModel.cpp index e866513c7..3c0648b38 100644 --- a/launcher/SwitcherModel.cpp +++ b/launcher/SwitcherModel.cpp @@ -29,6 +29,16 @@ using launcher::AbstractLauncherIcon; namespace switcher { +namespace +{ +bool compare_windows_by_active(Window first, Window second) +{ + WindowManager& wm = WindowManager::Default(); + return wm.GetWindowActiveNumber(first) > wm.GetWindowActiveNumber(second); +} + +} + SwitcherModel::SwitcherModel(std::vector<AbstractLauncherIcon::Ptr> icons) : _inner(icons) @@ -127,36 +137,30 @@ SwitcherModel::LastSelection() return _inner.at(_last_index); } -int -SwitcherModel::LastSelectionIndex() +int SwitcherModel::LastSelectionIndex() { return _last_index; } -bool -SwitcherModel::CompareWindowsByActive (guint32 first, guint32 second) +bool WindowOnOtherViewport(Window xid) { - return WindowManager::Default ()->GetWindowActiveNumber (first) > WindowManager::Default ()->GetWindowActiveNumber (second); + return !WindowManager::Default().IsWindowOnCurrentDesktop(xid); } -bool -WindowOnOtherViewport(Window xid) -{ - return !WindowManager::Default()->IsWindowOnCurrentDesktop(xid); -} - -std::vector<Window> -SwitcherModel::DetailXids() +std::vector<Window> SwitcherModel::DetailXids() { std::vector<Window> results; results = Selection()->Windows(); if (only_detail_on_viewport) { - results.erase(std::remove_if(results.begin(), results.end(), WindowOnOtherViewport), results.end()); + results.erase(std::remove_if(results.begin(), + results.end(), + WindowOnOtherViewport), + results.end()); } - std::sort (results.begin (), results.end (), &CompareWindowsByActive); + std::sort(results.begin(), results.end(), compare_windows_by_active); // swap so we focus the last focused window first if (Selection() == _last_active_icon && results.size () > 1) @@ -165,8 +169,7 @@ SwitcherModel::DetailXids() return results; } -Window -SwitcherModel::DetailSelectionWindow () +Window SwitcherModel::DetailSelectionWindow() { if (!detail_selection || DetailXids ().empty()) return 0; @@ -177,8 +180,7 @@ SwitcherModel::DetailSelectionWindow () return DetailXids()[detail_selection_index]; } -void -SwitcherModel::Next() +void SwitcherModel::Next() { _last_index = _index; @@ -191,8 +193,7 @@ SwitcherModel::Next() selection_changed.emit(Selection()); } -void -SwitcherModel::Prev() +void SwitcherModel::Prev() { _last_index = _index; @@ -206,8 +207,7 @@ SwitcherModel::Prev() selection_changed.emit(Selection()); } -void -SwitcherModel::NextDetail () +void SwitcherModel::NextDetail () { if (!detail_selection()) return; @@ -229,8 +229,7 @@ void SwitcherModel::PrevDetail () detail_selection_index = DetailXids().size() - 1; } -void -SwitcherModel::Select(AbstractLauncherIcon::Ptr const& selection) +void SwitcherModel::Select(AbstractLauncherIcon::Ptr const& selection) { int i = 0; for (iterator it = begin(), e = end(); it != e; ++it) diff --git a/launcher/SwitcherModel.h b/launcher/SwitcherModel.h index fd733681d..51230b65b 100644 --- a/launcher/SwitcherModel.h +++ b/launcher/SwitcherModel.h @@ -91,9 +91,6 @@ protected: void AddProperties(GVariantBuilder* builder); private: - - static bool CompareWindowsByActive (guint32 first, guint32 second); - Base _inner; unsigned int _index; unsigned int _last_index; diff --git a/panel/CMakeLists.txt b/panel/CMakeLists.txt index fc30d76f3..8ab407bb2 100644 --- a/panel/CMakeLists.txt +++ b/panel/CMakeLists.txt @@ -47,4 +47,4 @@ add_dependencies (panel-lib unity-core-${UNITY_API_VERSION} unity-shared) # add_executable (panel StandalonePanel.cpp) add_dependencies (panel panel-lib) -target_link_libraries (panel panel-lib unity-shared) +target_link_libraries (panel panel-lib unity-shared unity-shared-standalone) diff --git a/panel/PanelIndicatorEntryView.cpp b/panel/PanelIndicatorEntryView.cpp index 7354d6083..31d053d13 100644 --- a/panel/PanelIndicatorEntryView.cpp +++ b/panel/PanelIndicatorEntryView.cpp @@ -98,9 +98,9 @@ void PanelIndicatorEntryView::OnActiveChanged(bool is_active) void PanelIndicatorEntryView::ShowMenu(int button) { - auto wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); - if (!wm->IsExpoActive() && !wm->IsScaleActive()) + if (!wm.IsExpoActive() && !wm.IsScaleActive()) { proxy_->ShowMenu(GetAbsoluteX(), GetAbsoluteY() + panel::Style::Instance().panel_height, diff --git a/panel/PanelMenuView.cpp b/panel/PanelMenuView.cpp index 89e9aceac..01cf7846b 100644 --- a/panel/PanelMenuView.cpp +++ b/panel/PanelMenuView.cpp @@ -27,6 +27,7 @@ #include "unity-shared/UnitySettings.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UScreen.h" +#include "unity-shared/WindowManager.h" #include <UnityCore/Variant.h> @@ -103,7 +104,6 @@ PanelMenuView::PanelMenuView() _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); - //_window_buttons->mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); AddChild(_window_buttons.GetPointer()); layout_->SetLeftAndRightPadding(_window_buttons->GetContentWidth(), 0); @@ -119,22 +119,22 @@ PanelMenuView::PanelMenuView() _titlebar_grab_area->grab_end.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd)); AddChild(_titlebar_grab_area.GetPointer()); - WindowManager* win_manager = WindowManager::Default(); - win_manager->window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); - win_manager->window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized)); - win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized)); - win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored)); - win_manager->window_unmapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnmapped)); - win_manager->window_mapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMapped)); - win_manager->window_moved.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); - win_manager->window_resized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); - win_manager->window_decorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowDecorated)); - win_manager->window_undecorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUndecorated)); - win_manager->initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); - win_manager->terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); - win_manager->initiate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoInitiate)); - win_manager->terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); - win_manager->compiz_screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); + WindowManager& wm = WindowManager::Default(); + wm.window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); + wm.window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized)); + wm.window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized)); + wm.window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored)); + wm.window_unmapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnmapped)); + wm.window_mapped.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMapped)); + wm.window_moved.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); + wm.window_resized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMoved)); + wm.window_decorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowDecorated)); + wm.window_undecorated.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUndecorated)); + wm.initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); + wm.terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); + wm.initiate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoInitiate)); + wm.terminate_expo.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); + wm.screen_viewport_switch_ended.connect(sigc::mem_fun(this, &PanelMenuView::OnExpoTerminate)); _style_changed_connection = panel::Style::Instance().changed.connect([&] { _window_buttons->ComputeContentSize(); @@ -318,8 +318,8 @@ void PanelMenuView::OnFadeOutChanged(double progress) bool PanelMenuView::DrawMenus() const { - auto wm = WindowManager::Default(); - bool screen_grabbed = (wm->IsExpoActive() || wm->IsScaleActive()); + WindowManager& wm = WindowManager::Default(); + bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); if (_we_control_active && !_overlay_showing && !screen_grabbed && !_switcher_showing && !_launcher_keynav) @@ -335,8 +335,8 @@ bool PanelMenuView::DrawMenus() const bool PanelMenuView::DrawWindowButtons() const { - auto wm = WindowManager::Default(); - bool screen_grabbed = (wm->IsExpoActive() || wm->IsScaleActive()); + WindowManager& wm = WindowManager::Default(); + bool screen_grabbed = (wm.IsExpoActive() || wm.IsScaleActive()); if (_overlay_showing) return true; @@ -667,7 +667,7 @@ std::string PanelMenuView::GetActiveViewName(bool use_appname) const return ""; } - if (WindowManager::Default()->IsWindowMaximized(window_xid) && !use_appname) + if (WindowManager::Default().IsWindowMaximized(window_xid) && !use_appname) { label = glib::String(bamf_view_get_name(view)).Str(); } @@ -794,17 +794,17 @@ void PanelMenuView::Refresh(bool force) if (geo.width > _monitor_geo.width) return; - auto win_manager = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); std::string new_title; - if (win_manager->IsScaleActive()) + if (wm.IsScaleActive()) { - if (win_manager->IsScaleActiveForGroup()) + if (wm.IsScaleActiveForGroup()) new_title = GetActiveViewName(true); else if (_we_control_active) new_title = _desktop_name; } - else if (win_manager->IsExpoActive()) + else if (wm.IsExpoActive()) { new_title = _desktop_name; } @@ -1030,11 +1030,11 @@ void PanelMenuView::OnActiveWindowChanged(BamfMatcher *matcher, if (BAMF_IS_WINDOW(new_view)) { - WindowManager *wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); BamfWindow* window = reinterpret_cast<BamfWindow*>(new_view); guint32 xid = bamf_window_get_xid(window); _active_xid = xid; - _is_maximized = wm->IsWindowMaximized(xid); + _is_maximized = wm.IsWindowMaximized(xid); if (bamf_window_get_window_type(window) == BAMF_WINDOW_DESKTOP) _we_control_active = true; @@ -1048,9 +1048,9 @@ void PanelMenuView::OnActiveWindowChanged(BamfMatcher *matcher, // if we've just started tracking this window and it is maximized, let's // make sure it's undecorated just in case it slipped by us earlier // (I'm looking at you, Chromium!) - if (_is_maximized && wm->IsWindowDecorated(xid)) + if (_is_maximized && wm.IsWindowDecorated(xid)) { - wm->Undecorate(xid); + wm.Undecorate(xid); _maximized_set.insert(xid); } } @@ -1071,24 +1071,12 @@ void PanelMenuView::OnActiveWindowChanged(BamfMatcher *matcher, void PanelMenuView::OnSpreadInitiate() { - /*foreach (guint32 &xid, windows) - { - if (WindowManager::Default()->IsWindowMaximized(xid)) - WindowManager::Default()->Decorate(xid); - }*/ - Refresh(); QueueDraw(); } void PanelMenuView::OnSpreadTerminate() { - /*foreach (guint32 &xid, windows) - { - if (WindowManager::Default()->IsWindowMaximized(xid)) - WindowManager::Default()->Undecorate(xid); - }*/ - Refresh(); QueueDraw(); } @@ -1107,9 +1095,10 @@ void PanelMenuView::OnExpoTerminate() void PanelMenuView::OnWindowMinimized(guint32 xid) { - if (WindowManager::Default()->IsWindowMaximized(xid)) + WindowManager& wm = WindowManager::Default(); + if (wm.IsWindowMaximized(xid)) { - WindowManager::Default()->Decorate(xid); + wm.Decorate(xid); _maximized_set.erase(xid); Refresh(); @@ -1119,9 +1108,10 @@ void PanelMenuView::OnWindowMinimized(guint32 xid) void PanelMenuView::OnWindowUnminimized(guint32 xid) { - if (WindowManager::Default()->IsWindowMaximized(xid)) + WindowManager& wm = WindowManager::Default(); + if (wm.IsWindowMaximized(xid)) { - WindowManager::Default()->Undecorate(xid); + wm.Undecorate(xid); _maximized_set.insert(xid); Refresh(); @@ -1135,7 +1125,7 @@ void PanelMenuView::OnWindowUnmapped(guint32 xid) // we need to do this again on BamfView closed signal. if (_maximized_set.find(xid) != _maximized_set.end()) { - WindowManager::Default()->Decorate(xid); + WindowManager::Default().Decorate(xid); _maximized_set.erase(xid); _decor_map.erase(xid); @@ -1146,9 +1136,10 @@ void PanelMenuView::OnWindowUnmapped(guint32 xid) void PanelMenuView::OnWindowMapped(guint32 xid) { - if (WindowManager::Default()->IsWindowMaximized(xid)) + WindowManager& wm = WindowManager::Default(); + if (wm.IsWindowMaximized(xid)) { - WindowManager::Default()->Undecorate(xid); + wm.Undecorate(xid); _maximized_set.insert(xid); Refresh(); @@ -1162,7 +1153,7 @@ void PanelMenuView::OnWindowDecorated(guint32 xid) if (_maximized_set.find(xid) != _maximized_set.end ()) { - WindowManager::Default()->Undecorate(xid); + WindowManager::Default().Undecorate(xid); } } @@ -1187,10 +1178,11 @@ void PanelMenuView::OnWindowMaximized(guint xid) } // update the state of the window in the _decor_map - _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid); + WindowManager& wm = WindowManager::Default(); + _decor_map[xid] = wm.IsWindowDecorated(xid); if (_decor_map[xid]) - WindowManager::Default()->Undecorate(xid); + wm.Undecorate(xid); _maximized_set.insert(xid); @@ -1213,7 +1205,7 @@ void PanelMenuView::OnWindowRestored(guint xid) } if (_decor_map[xid]) - WindowManager::Default()->Decorate(xid); + WindowManager::Default().Decorate(xid); _maximized_set.erase(xid); @@ -1269,8 +1261,8 @@ bool PanelMenuView::IsWindowUnderOurControl(Window xid) const { if (UScreen::GetDefault()->GetMonitors().size() > 1) { - auto wm = WindowManager::Default(); - nux::Geometry const& window_geo = wm->GetWindowGeometry(xid); + WindowManager& wm = WindowManager::Default(); + nux::Geometry const& window_geo = wm.GetWindowGeometry(xid); nux::Geometry const& intersect = _monitor_geo.Intersect(window_geo); /* We only care of the horizontal window portion */ @@ -1282,11 +1274,11 @@ bool PanelMenuView::IsWindowUnderOurControl(Window xid) const bool PanelMenuView::IsValidWindow(Window xid) const { - auto wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); std::vector<Window> const& our_xids = nux::XInputWindow::NativeHandleList(); - if (wm->IsWindowOnCurrentDesktop(xid) && !wm->IsWindowObscured(xid) && - wm->IsWindowVisible(xid) && IsWindowUnderOurControl(xid) && + if (wm.IsWindowOnCurrentDesktop(xid) && !wm.IsWindowObscured(xid) && + wm.IsWindowVisible(xid) && IsWindowUnderOurControl(xid) && std::find(our_xids.begin(), our_xids.end(), xid) == our_xids.end()) { return true; @@ -1371,7 +1363,7 @@ void PanelMenuView::OnMaximizedActivate(int x, int y) if (maximized != 0) { - WindowManager::Default()->Activate(maximized); + WindowManager::Default().Activate(maximized); } } @@ -1384,7 +1376,7 @@ void PanelMenuView::OnMaximizedRestore(int x, int y) if (maximized != 0) { - WindowManager::Default()->Restore(maximized); + WindowManager::Default().Restore(maximized); _is_inside = true; } } @@ -1398,7 +1390,7 @@ void PanelMenuView::OnMaximizedLower(int x, int y) if (maximized != 0) { - WindowManager::Default()->Lower(maximized); + WindowManager::Default().Lower(maximized); } } @@ -1415,7 +1407,7 @@ void PanelMenuView::OnMaximizedGrabStart(int x, int y) if (maximized != 0) { /* Always activate the window in case it is on another monitor */ - WindowManager::Default()->Activate(maximized); + WindowManager::Default().Activate(maximized); _titlebar_grab_area->SetGrabbed(true); } } @@ -1443,9 +1435,9 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) if (!panel_geo.IsPointInside(x, y)) { - auto wm = WindowManager::Default(); - nux::Geometry const& restored_geo = wm->GetWindowSavedGeometry(maximized); - nux::Geometry const& workarea_geo = wm->GetWorkAreaGeometry(maximized); + WindowManager& wm = WindowManager::Default(); + nux::Geometry const& restored_geo = wm.GetWindowSavedGeometry(maximized); + nux::Geometry const& workarea_geo = wm.GetWorkAreaGeometry(maximized); /* By default try to restore the window horizontally-centered respect to the * pointer position, if it doesn't fit on that area try to keep it into the @@ -1464,8 +1456,8 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) restore_x = workarea_geo.x; } - wm->Activate(maximized); - wm->RestoreAt(maximized, restore_x, restore_y); + wm.Activate(maximized); + wm.RestoreAt(maximized, restore_x, restore_y); _is_inside = true; _is_grabbed = true; @@ -1474,7 +1466,7 @@ void PanelMenuView::OnMaximizedGrabMove(int x, int y) /* Ungrab the pointer and start the X move, to make the decorator handle it */ _titlebar_grab_area->SetGrabbed(false); - wm->StartMove(maximized, x, y); + wm.StartMove(maximized, x, y); } } } @@ -1643,6 +1635,7 @@ void PanelMenuView::SetMonitor(int monitor) _maximized_set.clear(); GList* windows = bamf_matcher_get_window_stack_for_monitor(_matcher, _monitor); + WindowManager& wm = WindowManager::Default(); for (GList* l = windows; l; l = l->next) { if (!BAMF_IS_WINDOW(l->data)) @@ -1660,10 +1653,10 @@ void PanelMenuView::SetMonitor(int monitor) { Window xid = bamf_window_get_xid(window); - _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid); + _decor_map[xid] = wm.IsWindowDecorated(xid); if (_decor_map[xid]) - WindowManager::Default()->Undecorate(xid); + wm.Undecorate(xid); _maximized_set.insert(xid); } diff --git a/panel/PanelMenuView.h b/panel/PanelMenuView.h index be7e452c3..f6d737bf3 100644 --- a/panel/PanelMenuView.h +++ b/panel/PanelMenuView.h @@ -29,7 +29,6 @@ #include "unity-shared/StaticCairoText.h" #include "WindowButtons.h" #include "PanelTitlebarGrabAreaView.h" -#include "unity-shared/PluginAdapter.h" #include "unity-shared/Animator.h" #include "unity-shared/UBusWrapper.h" diff --git a/panel/PanelView.cpp b/panel/PanelView.cpp index fe94e8777..ac2fad3c6 100644 --- a/panel/PanelView.cpp +++ b/panel/PanelView.cpp @@ -35,10 +35,11 @@ #include <glib.h> #include "unity-shared/PanelStyle.h" -#include "PanelIndicatorsView.h" +#include "unity-shared/WindowManager.h" +#include "unity-shared/UBusMessages.h" #include <UnityCore/Variant.h> -#include "unity-shared/UBusMessages.h" +#include "PanelIndicatorsView.h" #include "PanelView.h" @@ -580,11 +581,11 @@ PanelView::UpdateBackground() } else { - WindowManager* wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); double opacity = _opacity; - if (_opacity_maximized_toggle && (wm->IsExpoActive() || - (maximized_win != 0 && !wm->IsWindowObscured(maximized_win)))) + if (_opacity_maximized_toggle && (wm.IsExpoActive() || + (maximized_win != 0 && !wm.IsWindowObscured(maximized_win)))) { opacity = 1.0f; } @@ -812,21 +813,21 @@ void PanelView::SetOpacityMaximizedToggle(bool enabled) { if (enabled) { - auto win_manager = WindowManager::Default(); + WindowManager& win_manager = WindowManager::Default(); auto update_bg_lambda = [&](guint32) { ForceUpdateBackground(); }; auto conn = &_maximized_opacity_toggle_connections; - conn->push_back(win_manager->window_minimized.connect(update_bg_lambda)); - conn->push_back(win_manager->window_unminimized.connect(update_bg_lambda)); - conn->push_back(win_manager->window_maximized.connect(update_bg_lambda)); - conn->push_back(win_manager->window_restored.connect(update_bg_lambda)); - conn->push_back(win_manager->window_mapped.connect(update_bg_lambda)); - conn->push_back(win_manager->window_unmapped.connect(update_bg_lambda)); - conn->push_back(win_manager->initiate_expo.connect( + conn->push_back(win_manager.window_minimized.connect(update_bg_lambda)); + conn->push_back(win_manager.window_unminimized.connect(update_bg_lambda)); + conn->push_back(win_manager.window_maximized.connect(update_bg_lambda)); + conn->push_back(win_manager.window_restored.connect(update_bg_lambda)); + conn->push_back(win_manager.window_mapped.connect(update_bg_lambda)); + conn->push_back(win_manager.window_unmapped.connect(update_bg_lambda)); + conn->push_back(win_manager.initiate_expo.connect( sigc::mem_fun(this, &PanelView::ForceUpdateBackground))); - conn->push_back(win_manager->terminate_expo.connect( + conn->push_back(win_manager.terminate_expo.connect( sigc::mem_fun(this, &PanelView::ForceUpdateBackground))); - conn->push_back(win_manager->compiz_screen_viewport_switch_ended.connect( + conn->push_back(win_manager.screen_viewport_switch_ended.connect( sigc::mem_fun(this, &PanelView::ForceUpdateBackground))); } else diff --git a/panel/WindowButtons.cpp b/panel/WindowButtons.cpp index 6d8e7d15b..cce583ef3 100644 --- a/panel/WindowButtons.cpp +++ b/panel/WindowButtons.cpp @@ -442,7 +442,7 @@ void WindowButtons::OnCloseClicked(nux::Button *button) } else { - WindowManager::Default()->Close(window_xid_); + WindowManager::Default().Close(window_xid_); } close_clicked.emit(); @@ -456,7 +456,7 @@ void WindowButtons::OnMinimizeClicked(nux::Button *button) return; if (!win_button->IsOverlayOpen()) - WindowManager::Default()->Minimize(window_xid_); + WindowManager::Default().Minimize(window_xid_); minimize_clicked.emit(); } @@ -474,12 +474,12 @@ void WindowButtons::OnRestoreClicked(nux::Button *button) } else { - WindowManager* wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); Window to_restore = window_xid_; - wm->Raise(to_restore); - wm->Activate(to_restore); - wm->Restore(to_restore); + wm.Raise(to_restore); + wm.Activate(to_restore); + wm.Restore(to_restore); } restore_clicked.emit(); @@ -597,6 +597,7 @@ void WindowButtons::OnOverlayHidden(GVariant* data) active_overlay_ = ""; + WindowManager& wm = WindowManager::Default(); for (auto area : GetChildren()) { auto button = dynamic_cast<WindowButton*>(area); @@ -607,13 +608,13 @@ void WindowButtons::OnOverlayHidden(GVariant* data) { if (button->GetType() == panel::WindowButtonType::CLOSE) { - bool closable = WindowManager::Default()->IsWindowClosable(window_xid_); + bool closable = wm.IsWindowClosable(window_xid_); button->SetEnabled(closable); } if (button->GetType() == panel::WindowButtonType::MINIMIZE) { - bool minimizable = WindowManager::Default()->IsWindowMinimizable(window_xid_); + bool minimizable = wm.IsWindowMinimizable(window_xid_); button->SetEnabled(minimizable); } } @@ -744,6 +745,7 @@ void WindowButtons::SetControlledWindow(Window xid) if (window_xid_ && active_overlay_.empty()) { + WindowManager& wm = WindowManager::Default(); for (auto area : GetChildren()) { auto button = dynamic_cast<WindowButton*>(area); @@ -753,13 +755,13 @@ void WindowButtons::SetControlledWindow(Window xid) if (button->GetType() == panel::WindowButtonType::CLOSE) { - bool closable = WindowManager::Default()->IsWindowClosable(xid); + bool closable = wm.IsWindowClosable(xid); button->SetEnabled(closable); } if (button->GetType() == panel::WindowButtonType::MINIMIZE) { - bool minimizable = WindowManager::Default()->IsWindowMinimizable(xid); + bool minimizable = wm.IsWindowMinimizable(xid); button->SetEnabled(minimizable); } } diff --git a/plugins/unityshell/src/WindowGestureTarget.cpp b/plugins/unityshell/src/WindowGestureTarget.cpp index 8bcaa7b40..beeb7830f 100644 --- a/plugins/unityshell/src/WindowGestureTarget.cpp +++ b/plugins/unityshell/src/WindowGestureTarget.cpp @@ -25,6 +25,7 @@ #include <Nux/Nux.h> // otherwise unityshell.h inclusion will cause failures #include "unityshell.h" +// To make the gesture tests pass, this has to be a local include. #include "PluginAdapter.h" using namespace nux; @@ -67,7 +68,7 @@ GestureDeliveryRequest WindowGestureTarget::GestureEvent(const nux::GestureEvent switch (event.type) { case nux::EVENT_GESTURE_BEGIN: - PluginAdapter::Default()->ShowGrabHandles(window_, false); + PluginAdapter::Default().ShowGrabHandles(window_, false); break; case EVENT_GESTURE_UPDATE: if (event.GetGestureClasses() & PINCH_GESTURE) @@ -91,7 +92,7 @@ GestureDeliveryRequest WindowGestureTarget::GestureEvent(const nux::GestureEvent EndWindowMove(event); started_window_move_ = false; } - PluginAdapter::Default()->ShowGrabHandles(window_, true); + PluginAdapter::Default().ShowGrabHandles(window_, true); break; }; diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index c2f841407..03c2becff 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -242,8 +242,7 @@ UnityScreen::UnityScreen(CompScreen* screen) GLScreenInterface::setHandler(gScreen); PluginAdapter::Initialize(screen); - WindowManager::SetDefault(PluginAdapter::Default()); - AddChild(PluginAdapter::Default()); + AddChild(&WindowManager::Default()); StartupNotifyService::Default()->SetSnDisplay(screen->snDisplay(), screen->screenNum()); @@ -565,7 +564,7 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip) if (sources_.GetSource(local::RELAYOUT_TIMEOUT)) return; - if (PluginAdapter::Default()->IsExpoActive()) + if (WindowManager::Default().IsExpoActive()) return; CompOutput* output = _last_output; @@ -691,7 +690,7 @@ void UnityScreen::OnPanelStyleChanged() // Reload the windows themed textures UnityWindow::CleanupSharedTextures(); - if (WindowManager::Default()->IsScaleActive()) + if (WindowManager::Default().IsScaleActive()) { UnityWindow::SetupSharedTextures(); @@ -840,7 +839,7 @@ bool UnityScreen::forcePaintOnTop () { return !allowWindowPaint || ((switcher_controller_->Visible() || - PluginAdapter::Default()->IsExpoActive()) + WindowManager::Default().IsExpoActive()) && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL)))); } @@ -905,7 +904,7 @@ void UnityScreen::enterShowDesktopMode () w->moveInputFocusTo(); } - PluginAdapter::Default()->OnShowDesktop(); + PluginAdapter::Default().OnShowDesktop(); /* Disable the focus handler as we will report that * minimized windows can be focused which will @@ -944,7 +943,7 @@ void UnityScreen::leaveShowDesktopMode (CompWindow *w) } } - PluginAdapter::Default()->OnLeaveDesktop(); + PluginAdapter::Default().OnLeaveDesktop(); screen->leaveShowDesktopMode (w); } @@ -1487,16 +1486,16 @@ void UnityScreen::nuxDamageCompiz() void UnityScreen::handleEvent(XEvent* event) { bool skip_other_plugins = false; - auto wm = PluginAdapter::Default(); + PluginAdapter& wm = PluginAdapter::Default(); switch (event->type) { case FocusIn: case FocusOut: if (event->xfocus.mode == NotifyGrab) - wm->OnScreenGrabbed(); + wm.OnScreenGrabbed(); else if (event->xfocus.mode == NotifyUngrab) - wm->OnScreenUngrabbed(); + wm.OnScreenUngrabbed(); if (_key_nav_mode_requested) { @@ -1511,7 +1510,7 @@ void UnityScreen::handleEvent(XEvent* event) _key_nav_mode_requested = false; break; case MotionNotify: - if (wm->IsScaleActive()) + if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) @@ -1524,7 +1523,7 @@ void UnityScreen::handleEvent(XEvent* event) launcher_controller_->KeyNavTerminate(false); EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); } - if (wm->IsScaleActive()) + if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) @@ -1572,7 +1571,7 @@ void UnityScreen::handleEvent(XEvent* event) } } } - else if (wm->IsScaleActive()) + else if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) @@ -1672,11 +1671,11 @@ void UnityScreen::handleEvent(XEvent* event) case PropertyNotify: if (event->xproperty.atom == Atoms::mwmHints) { - PluginAdapter::Default ()->NotifyNewDecorationState(event->xproperty.window); + PluginAdapter::Default().NotifyNewDecorationState(event->xproperty.window); } break; case MapRequest: - ShowdesktopHandler::AllowLeaveShowdesktopMode (event->xmaprequest.window); + ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window); break; } @@ -1698,7 +1697,8 @@ void UnityScreen::handleCompizEvent(const char* plugin, const char* event, CompOption::Vector& option) { - PluginAdapter::Default()->NotifyCompizEvent(plugin, event, option); + PluginAdapter& adapter = PluginAdapter::Default(); + adapter.NotifyCompizEvent(plugin, event, option); compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::handleCompizEvent (plugin, event, option); if (launcher_controller_->IsOverlayOpen() && g_strcmp0(event, "start_viewport_switch") == 0) @@ -1706,7 +1706,7 @@ void UnityScreen::handleCompizEvent(const char* plugin, ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); } - if (PluginAdapter::Default()->IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && + if (adapter.IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && super_keypressed_) { scale_just_activated_ = true; @@ -1761,9 +1761,11 @@ bool UnityScreen::showLauncherKeyTerminate(CompAction* action, // hack...if the scale just wasn't activated AND the 'when' time is within time to start the // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state... - if (PluginAdapter::Default()->IsScaleActive() && !scale_just_activated_ && launcher_controller_->AboutToShowDash(true, when)) + PluginAdapter& adapter = PluginAdapter::Default(); + if (adapter.IsScaleActive() && !scale_just_activated_ && + launcher_controller_->AboutToShowDash(true, when)) { - PluginAdapter::Default()->TerminateScale(); + adapter.TerminateScale(); was_tap = true; } else if (scale_just_activated_) @@ -1838,9 +1840,10 @@ void UnityScreen::SendExecuteCommand() hud_controller_->HideHud(); } - if (PluginAdapter::Default()->IsScaleActive()) + PluginAdapter& adapter = PluginAdapter::Default(); + if (adapter.IsScaleActive()) { - PluginAdapter::Default()->TerminateScale(); + adapter.TerminateScale(); } ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, @@ -1968,7 +1971,7 @@ bool UnityScreen::altTabForwardAllInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) { - if (WindowManager::Default()->IsWallActive()) + if (WindowManager::Default().IsWallActive()) return false; else if (switcher_controller_->Visible()) switcher_controller_->Next(); @@ -2143,7 +2146,7 @@ void UnityScreen::RestoreWindow(GVariant* data) // Return input-focus to previously focused window (before key-nav-mode was // entered) if (preserve_focus) - PluginAdapter::Default ()->restoreInputFocus (); + PluginAdapter::Default().RestoreInputFocus (); } bool UnityScreen::SaveInputThenFocus(const guint xid) @@ -2153,7 +2156,7 @@ bool UnityScreen::SaveInputThenFocus(const guint xid) // check if currently focused window isn't it self if (xid != screen->activeWindow()) - PluginAdapter::Default()->saveInputFocus(); + PluginAdapter::Default().SaveInputFocus(); // set input-focus on window if (newFocusedWindow) @@ -2253,7 +2256,7 @@ bool UnityScreen::ShowHudTerminate(CompAction* action, bool UnityScreen::initPluginActions() { CompPlugin* p = CompPlugin::find("expo"); - + PluginAdapter& adapter = PluginAdapter::Default(); if (p) { MultiActionList expoActions; @@ -2277,7 +2280,7 @@ bool UnityScreen::initPluginActions() } } - PluginAdapter::Default()->SetExpoAction(expoActions); + adapter.SetExpoAction(expoActions); } p = CompPlugin::find("scale"); @@ -2312,7 +2315,7 @@ bool UnityScreen::initPluginActions() } } - PluginAdapter::Default()->SetScaleAction(scaleActions); + adapter.SetScaleAction(scaleActions); } p = CompPlugin::find("unitymtgrabhandles"); @@ -2322,11 +2325,11 @@ bool UnityScreen::initPluginActions() foreach(CompOption & option, p->vTable->getOptions()) { if (option.name() == "show_handles_key") - PluginAdapter::Default()->SetShowHandlesAction(&option.value().action()); + adapter.SetShowHandlesAction(&option.value().action()); else if (option.name() == "hide_handles_key") - PluginAdapter::Default()->SetHideHandlesAction(&option.value().action()); + adapter.SetHideHandlesAction(&option.value().action()); else if (option.name() == "toggle_handles_key") - PluginAdapter::Default()->SetToggleHandlesAction(&option.value().action()); + adapter.SetToggleHandlesAction(&option.value().action()); } } @@ -2479,7 +2482,7 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, if (uScreen->doShellRepaint && !uScreen->paint_panel_ && window->type() == CompWindowTypeNormalMask) { guint32 id = window->id(); - bool maximized = WindowManager::Default()->IsWindowMaximized(id); + bool maximized = WindowManager::Default().IsWindowMaximized(id); bool on_current = window->onCurrentDesktop(); bool override_redirect = window->overrideRedirect(); bool managed = window->managed(); @@ -2518,7 +2521,8 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, uScreen->paintPanelShadow(region); } - if (WindowManager::Default()->IsScaleActive() && ScaleScreen::get(screen)->getSelectedWindow() == window->id()) + if (WindowManager::Default().IsScaleActive() && + ScaleScreen::get(screen)->getSelectedWindow() == window->id()) { if (!region.isEmpty()) { @@ -2629,7 +2633,7 @@ UnityWindow::minimized () /* Called whenever a window is mapped, unmapped, minimized etc */ void UnityWindow::windowNotify(CompWindowNotify n) { - PluginAdapter::Default()->Notify(window, n); + PluginAdapter::Default().Notify(window, n); switch (n) { @@ -2730,7 +2734,7 @@ void UnityWindow::stateChangeNotify(unsigned int lastState) !(window->state () & CompWindowStateFullscreenMask)) UnityScreen::get (screen)->fullscreen_windows_.remove(window); - PluginAdapter::Default()->NotifyStateChange(window, window->state(), lastState); + PluginAdapter::Default().NotifyStateChange(window, window->state(), lastState); window->stateChangeNotify(lastState); } @@ -2750,13 +2754,13 @@ void UnityWindow::updateFrameRegion(CompRegion ®ion) void UnityWindow::moveNotify(int x, int y, bool immediate) { - PluginAdapter::Default()->NotifyMoved(window, x, y); + PluginAdapter::Default().NotifyMoved(window, x, y); window->moveNotify(x, y, immediate); } void UnityWindow::resizeNotify(int x, int y, int w, int h) { - PluginAdapter::Default()->NotifyResized(window, x, y, w, h); + PluginAdapter::Default().NotifyResized(window, x, y, w, h); window->resizeNotify(x, y, w, h); } @@ -2814,7 +2818,7 @@ CompPoint UnityWindow::tryNotIntersectUI(CompPoint& pos) bool UnityWindow::place(CompPoint& pos) { - bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window); + bool was_maximized = PluginAdapter::Default().MaximizeIfBigEnough(window); if (!was_maximized) { @@ -2956,12 +2960,12 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num) BackgroundEffectHelper::blur_type = (unity::BlurType)optionGetDashBlurExperimental(); break; case UnityshellOptions::AutomaximizeValue: - PluginAdapter::Default()->SetCoverageAreaBeforeAutomaximize(optionGetAutomaximizeValue() / 100.0f); + PluginAdapter::Default().SetCoverageAreaBeforeAutomaximize(optionGetAutomaximizeValue() / 100.0f); break; case UnityshellOptions::AltTabTimeout: switcher_controller_->detail_on_timeout = optionGetAltTabTimeout(); case UnityshellOptions::AltTabBiasViewport: - PluginAdapter::Default()->bias_active_to_viewport = optionGetAltTabBiasViewport(); + PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport(); break; case UnityshellOptions::DisableShowDesktop: switcher_controller_->SetShowDesktopDisabled(optionGetDisableShowDesktop()); @@ -3537,22 +3541,23 @@ UnityWindow::UnityWindow(CompWindow* window) } } } - - WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpread)); - WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpread)); + WindowManager& wm = WindowManager::Default(); + wm.initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpread)); + wm.terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpread)); } + void UnityWindow::AddProperties(GVariantBuilder* builder) { Window xid = window->id(); auto const& swins = ScaleScreen::get(screen)->getWindows(); bool scaled = std::find(swins.begin(), swins.end(), ScaleWindow::get(window)) != swins.end(); - auto wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); variant::BuilderWrapper(builder) - .add(scaled ? GetScaledGeometry() : wm->GetWindowGeometry(xid)) + .add(scaled ? GetScaledGeometry() : wm.GetWindowGeometry(xid)) .add("xid", xid) - .add("title", wm->GetWindowName(xid)) + .add("title", wm.GetWindowName(xid)) .add("scaled", scaled) .add("scaled_close_x", close_button_geo_.x) .add("scaled_close_y", close_button_geo_.y) @@ -3566,8 +3571,12 @@ std::string UnityWindow::GetName() const } -void UnityWindow::DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const& attrib, - GLMatrix const& transform, unsigned int mask, int x, int y, double scale) +void UnityWindow::DrawTexture(GLTexture::List const& textures, + GLWindowPaintAttrib const& attrib, + GLMatrix const& transform, + unsigned int mask, + int x, int y, + double scale) { for (auto const& texture : textures) { @@ -3641,7 +3650,7 @@ void UnityWindow::RenderText(CairoContext const& context, int x, int y, int widt pango_cairo_context_set_resolution(pango_ctx, dpi / static_cast<float>(PANGO_SCALE)); pango_layout_context_changed(layout); - decoration_title_ = WindowManager::Default()->GetWindowName(window->id()); + decoration_title_ = WindowManager::Default().GetWindowName(window->id()); pango_layout_set_height(layout, height); pango_layout_set_width(layout, -1); //avoid wrap lines pango_layout_set_auto_dir(layout, false); @@ -3702,7 +3711,7 @@ void UnityWindow::BuildDecorationTexture() auto const& border_extents = window->border(); - if (WindowManager::Default()->IsWindowDecorated(window->id()) && border_extents.top > 0) + if (WindowManager::Default().IsWindowDecorated(window->id()) && border_extents.top > 0) { CairoContext context(window->borderRect().width(), border_extents.top); RenderDecoration(context); @@ -3815,7 +3824,7 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, if (texture->width() == width && texture->height() == height) { - if (decoration_title_ == WindowManager::Default()->GetWindowName(window->id())) + if (decoration_title_ == WindowManager::Default().GetWindowName(window->id())) redraw_decoration = false; } } @@ -3878,20 +3887,20 @@ void UnityWindow::OnInitiateSpread() middle_clicked_ = false; SetupSharedTextures(); - WindowManager *wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); Window xid = window->id(); - if (wm->IsWindowDecorated(xid)) - wm->Decorate(xid); + if (wm.IsWindowDecorated(xid)) + wm.Decorate(xid); } void UnityWindow::OnTerminateSpread() { - WindowManager *wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); Window xid = window->id(); - if (wm->IsWindowDecorated(xid) && wm->IsWindowMaximized(xid)) - wm->Undecorate(xid); + if (wm.IsWindowDecorated(xid) && wm.IsWindowMaximized(xid)) + wm.Undecorate(xid); CleanupCachedTextures(); } @@ -3919,7 +3928,7 @@ UnityWindow::~UnityWindow() if (window->state () & CompWindowStateFullscreenMask) UnityScreen::get (screen)->fullscreen_windows_.remove(window); - PluginAdapter::Default ()->OnWindowClosed(window); + PluginAdapter::Default().OnWindowClosed(window); } diff --git a/shortcuts/ShortcutController.cpp b/shortcuts/ShortcutController.cpp index 995021bbf..62090604f 100644 --- a/shortcuts/ShortcutController.cpp +++ b/shortcuts/ShortcutController.cpp @@ -19,7 +19,6 @@ #include "ShortcutController.h" #include "unity-shared/UBusMessages.h" -#include "unity-shared/WindowManager.h" namespace unity { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5679ba917..ef3f5b4a7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -168,6 +168,7 @@ if (GTEST_SRC_DIR AND ${CMAKE_SOURCE_DIR}/unity-shared/Timer.cpp ${UNITY_SRC}/UnityshellPrivate.cpp ${CMAKE_SOURCE_DIR}/unity-shared/WindowManager.cpp + ${CMAKE_SOURCE_DIR}/unity-shared/StandaloneWindowManager.cpp ${UNITY_SRC}/UnityShowdesktopHandler.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle.cpp ${CMAKE_SOURCE_DIR}/plugins/unity-mt-grab-handles/src/unity-mt-grab-handle-group.cpp @@ -338,11 +339,11 @@ if (GTEST_SRC_DIR AND ${CMAKE_SOURCE_DIR}/unity-shared/OverlayRenderer.cpp ${CMAKE_SOURCE_DIR}/unity-shared/PanelStyle.cpp ${CMAKE_SOURCE_DIR}/unity-shared/PlacesVScrollBar.cpp - ${CMAKE_SOURCE_DIR}/unity-shared/PluginAdapterStandalone.cpp ${CMAKE_SOURCE_DIR}/unity-shared/PreviewStyle.cpp ${CMAKE_SOURCE_DIR}/unity-shared/RatingsButton.cpp ${CMAKE_SOURCE_DIR}/unity-shared/SearchBar.cpp ${CMAKE_SOURCE_DIR}/unity-shared/SearchBarSpinner.cpp + ${CMAKE_SOURCE_DIR}/unity-shared/StandaloneWindowManager.cpp ${CMAKE_SOURCE_DIR}/unity-shared/StaticCairoText.cpp ${CMAKE_SOURCE_DIR}/unity-shared/TextureCache.cpp ${CMAKE_SOURCE_DIR}/unity-shared/Timer.cpp diff --git a/tests/test-gestures/CMakeLists.txt b/tests/test-gestures/CMakeLists.txt index 00ef9e450..cd53347f7 100644 --- a/tests/test-gestures/CMakeLists.txt +++ b/tests/test-gestures/CMakeLists.txt @@ -56,6 +56,10 @@ if (GTEST_SRC_DIR) # Clean-up includes and definitions made in ../CmakeLists.txt remove_definitions(${CFLAGS}) set_directory_properties(PROPERTY INCLUDE_DIRECTORIES "") + + include_directories (${CMAKE_SOURCE_DIR}) + include_directories (${CMAKE_SOURCE_DIR}/unity-shared) + # And make our own pkg_check_modules (TEST_GESTURES_DEPS REQUIRED QUIET "${UNITY_PLUGIN_DEPS}") set(TEST_GESTURES_CFLAGS diff --git a/tests/test-gestures/PluginAdapterMock.cpp b/tests/test-gestures/PluginAdapterMock.cpp index a71af2421..3b904c1af 100644 --- a/tests/test-gestures/PluginAdapterMock.cpp +++ b/tests/test-gestures/PluginAdapterMock.cpp @@ -22,11 +22,11 @@ PluginAdapterMock *PluginAdapterMock::_default = 0; -PluginAdapterMock *PluginAdapterMock::Default() { +PluginAdapterMock& PluginAdapterMock::Default() { if (!_default) { _default = new PluginAdapterMock; } - return _default; + return *_default; } void PluginAdapterMock::ShowGrabHandles(CompWindowMock* window, bool use_timer) { diff --git a/tests/test-gestures/PluginAdapterMock.h b/tests/test-gestures/PluginAdapterMock.h index 2b111a68b..72faaff32 100644 --- a/tests/test-gestures/PluginAdapterMock.h +++ b/tests/test-gestures/PluginAdapterMock.h @@ -23,9 +23,10 @@ #include <compiz_mock/core/core.h> + class PluginAdapterMock { public: - static PluginAdapterMock *Default(); + static PluginAdapterMock& Default(); void ShowGrabHandles(CompWindowMock* window, bool use_timer); diff --git a/tests/test_desktop_launcher_icon.cpp b/tests/test_desktop_launcher_icon.cpp index 2a4828e11..9320d280a 100644 --- a/tests/test_desktop_launcher_icon.cpp +++ b/tests/test_desktop_launcher_icon.cpp @@ -19,8 +19,8 @@ #include <gmock/gmock.h> -#include "PluginAdapter.h" -#include "DesktopLauncherIcon.h" +#include "unity-shared/WindowManager.h" +#include "launcher/DesktopLauncherIcon.h" using namespace unity; using namespace unity::launcher; @@ -50,15 +50,15 @@ TEST_F(TestDesktopLauncherIcon, Position) TEST_F(TestDesktopLauncherIcon, ActivateToggleShowDesktop) { - auto plugin_adapter = PluginAdapter::Default(); + WindowManager& wm = WindowManager::Default(); - ASSERT_FALSE(plugin_adapter->InShowDesktop()); + ASSERT_FALSE(wm.InShowDesktop()); icon.Activate(ActionArg()); - ASSERT_TRUE(plugin_adapter->InShowDesktop()); + ASSERT_TRUE(wm.InShowDesktop()); icon.Activate(ActionArg()); - EXPECT_FALSE(plugin_adapter->InShowDesktop()); + EXPECT_FALSE(wm.InShowDesktop()); } TEST_F(TestDesktopLauncherIcon, ShowInSwitcher) diff --git a/tests/test_expo_launcher_icon.cpp b/tests/test_expo_launcher_icon.cpp index e1550fc43..8d04d8619 100644 --- a/tests/test_expo_launcher_icon.cpp +++ b/tests/test_expo_launcher_icon.cpp @@ -19,8 +19,8 @@ #include <gmock/gmock.h> -#include "ExpoLauncherIcon.h" -#include "PluginAdapter.h" +#include "launcher/ExpoLauncherIcon.h" +#include "unity-shared/WindowManager.h" using namespace unity; using namespace unity::launcher; @@ -34,15 +34,15 @@ struct TestExpoLauncherIcon : testing::Test TEST_F(TestExpoLauncherIcon, ActivateToggleExpo) { - auto plugin_adapter = PluginAdapter::Default(); + WindowManager& wm = WindowManager::Default(); - ASSERT_FALSE(plugin_adapter->IsExpoActive()); + ASSERT_FALSE(wm.IsExpoActive()); icon.Activate(ActionArg()); - ASSERT_TRUE(plugin_adapter->IsExpoActive()); + ASSERT_TRUE(wm.IsExpoActive()); icon.Activate(ActionArg()); - EXPECT_FALSE(plugin_adapter->IsExpoActive()); + EXPECT_FALSE(wm.IsExpoActive()); } TEST_F(TestExpoLauncherIcon, Position) diff --git a/tests/test_launcher_drag_window.cpp b/tests/test_launcher_drag_window.cpp index 2a5186d18..a1b1a0793 100644 --- a/tests/test_launcher_drag_window.cpp +++ b/tests/test_launcher_drag_window.cpp @@ -72,7 +72,7 @@ TEST_F(TestLauncherDragWindow, CancelsOnWindowMapped) { bool got_signal; drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; }); - WindowManager::Default()->window_mapped.emit(0); + WindowManager::Default().window_mapped.emit(0); EXPECT_TRUE(got_signal); EXPECT_TRUE(drag_window.Cancelled()); @@ -82,7 +82,7 @@ TEST_F(TestLauncherDragWindow, CancelsOnWindowUnmapped) { bool got_signal; drag_window.drag_cancel_request.connect([&got_signal] { got_signal = true; }); - WindowManager::Default()->window_unmapped.emit(0); + WindowManager::Default().window_unmapped.emit(0); EXPECT_TRUE(got_signal); EXPECT_TRUE(drag_window.Cancelled()); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index ce210ddec..fa4a8abd4 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -4,7 +4,6 @@ #include <NuxCore/Logger.h> #include <Nux/Nux.h> -#include "unity-shared/PluginAdapter.h" #include "unity-shared/WindowManager.h" int main(int argc, char** argv) @@ -24,10 +23,7 @@ int main(int argc, char** argv) // but you can still change it if you're debugging ;) nux::logging::configure_logging(::getenv("UNITY_LOG_SEVERITY")); - // Setting the PluginAdapter to null, using the Standalone version at link time. - PluginAdapter::Initialize(NULL); - WindowManager::SetDefault(PluginAdapter::Default()); - + // StandaloneWindowManager brought in at link time. int ret = RUN_ALL_TESTS(); return ret; diff --git a/unity-shared/BackgroundEffectHelper.cpp b/unity-shared/BackgroundEffectHelper.cpp index 2d3be7ef4..f9078b801 100644 --- a/unity-shared/BackgroundEffectHelper.cpp +++ b/unity-shared/BackgroundEffectHelper.cpp @@ -29,7 +29,6 @@ #undef FALSE #endif -#include <X11/Xregion.h> #include <boost/utility.hpp> #include "UnitySettings.h" diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index c2c5b9562..dbb4b28a8 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -64,6 +64,7 @@ set (UNITY_SHARED_SOURCES UnityWindowView.cpp UserThumbnailProvider.cpp WindowManager.cpp + XWindowManager.cpp ubus-server.cpp ) @@ -77,7 +78,7 @@ add_dependencies (unity-shared unity-core-${UNITY_API_VERSION}) # compiz set (UNITY_SHARED_COMPIZ_SOURCES - PluginAdapterCompiz.cpp + PluginAdapter.cpp ) add_library (unity-shared-compiz STATIC ${UNITY_SHARED_COMPIZ_SOURCES}) target_link_libraries (unity-shared-compiz ${LIBS}) @@ -86,7 +87,7 @@ add_dependencies (unity-shared-compiz unity-shared) # standalone set (UNITY_SHARED_STANDALONE_SOURCES - PluginAdapterStandalone.cpp + StandaloneWindowManager.cpp ) add_library (unity-shared-standalone STATIC ${UNITY_SHARED_STANDALONE_SOURCES}) target_link_libraries (unity-shared-standalone ${LIBS}) diff --git a/unity-shared/PluginAdapterCompiz.cpp b/unity-shared/PluginAdapter.cpp index 23702bf7f..8aa4c3723 100644 --- a/unity-shared/PluginAdapterCompiz.cpp +++ b/unity-shared/PluginAdapter.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -25,6 +25,8 @@ #include <NuxCore/Logger.h> #include <UnityCore/Variant.h> +namespace unity +{ namespace { @@ -33,10 +35,9 @@ nux::logging::Logger logger("unity.plugin"); const int THRESHOLD_HEIGHT = 600; const int THRESHOLD_WIDTH = 1024; +std::shared_ptr<PluginAdapter> global_instance; } -PluginAdapter* PluginAdapter::_default = 0; - #define MAXIMIZABLE (CompWindowActionMaximizeHorzMask & CompWindowActionMaximizeVertMask & CompWindowActionResizeMask) #define MWM_HINTS_FUNCTIONS (1L << 0) @@ -44,20 +45,23 @@ PluginAdapter* PluginAdapter::_default = 0; #define MWM_HINTS_UNDECORATED_UNITY 0x80 #define _XA_MOTIF_WM_HINTS "_MOTIF_WM_HINTS" + +WindowManagerPtr create_window_manager() +{ + return global_instance; +} + /* static */ -PluginAdapter* -PluginAdapter::Default() +PluginAdapter& PluginAdapter::Default() { - if (!_default) - return 0; - return _default; + // Better hope that initialize has been called first. + return *global_instance; } /* static */ -void -PluginAdapter::Initialize(CompScreen* screen) +void PluginAdapter::Initialize(CompScreen* screen) { - _default = new PluginAdapter(screen); + global_instance.reset(new PluginAdapter(screen)); } PluginAdapter::PluginAdapter(CompScreen* screen) : @@ -82,10 +86,9 @@ PluginAdapter::~PluginAdapter() } /* A No-op for now, but could be useful later */ -void -PluginAdapter::OnScreenGrabbed() +void PluginAdapter::OnScreenGrabbed() { - compiz_screen_grabbed.emit(); + screen_grabbed.emit(); if (!_spread_state && screen->grabExist("scale")) { @@ -100,8 +103,7 @@ PluginAdapter::OnScreenGrabbed() } } -void -PluginAdapter::OnScreenUngrabbed() +void PluginAdapter::OnScreenUngrabbed() { if (_spread_state && !screen->grabExist("scale")) { @@ -116,58 +118,53 @@ PluginAdapter::OnScreenUngrabbed() terminate_expo.emit(); } - compiz_screen_ungrabbed.emit(); + screen_ungrabbed.emit(); } -void -PluginAdapter::NotifyResized(CompWindow* window, int x, int y, int w, int h) +void PluginAdapter::NotifyResized(CompWindow* window, int x, int y, int w, int h) { window_resized.emit(window->id()); } -void -PluginAdapter::NotifyMoved(CompWindow* window, int x, int y) +void PluginAdapter::NotifyMoved(CompWindow* window, int x, int y) { window_moved.emit(window->id()); } -void -PluginAdapter::NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state) +void PluginAdapter::NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state) { if (!((last_state & MAXIMIZE_STATE) == MAXIMIZE_STATE) && ((state & MAXIMIZE_STATE) == MAXIMIZE_STATE)) { - WindowManager::window_maximized.emit(window->id()); + window_maximized.emit(window->id()); } else if (((last_state & MAXIMIZE_STATE) == MAXIMIZE_STATE) && !((state & MAXIMIZE_STATE) == MAXIMIZE_STATE)) { - WindowManager::window_restored.emit(window->id()); + window_restored.emit(window->id()); } } -void -PluginAdapter::NotifyNewDecorationState(guint32 xid) +void PluginAdapter::NotifyNewDecorationState(Window xid) { - bool wasTracked = (_window_decoration_state.find (xid) != _window_decoration_state.end ()); + bool wasTracked = (_window_decoration_state.find(xid) != _window_decoration_state.end()); bool wasDecorated = false; if (wasTracked) wasDecorated = _window_decoration_state[xid]; - bool decorated = IsWindowDecorated (xid); + bool decorated = IsWindowDecorated(xid); if (decorated == wasDecorated) return; if (decorated && (!wasDecorated || !wasTracked)) - WindowManager::window_decorated.emit(xid); + window_decorated.emit(xid); else if (wasDecorated || !wasTracked) - WindowManager::window_undecorated.emit(xid); + window_undecorated.emit(xid); } -void -PluginAdapter::Notify(CompWindow* window, CompWindowNotify notify) +void PluginAdapter::Notify(CompWindow* window, CompWindowNotify notify) { switch (notify) { @@ -190,38 +187,36 @@ PluginAdapter::Notify(CompWindow* window, CompWindowNotify notify) window_shown.emit(window->id()); break; case CompWindowNotifyMap: - WindowManager::window_mapped.emit(window->id()); + window_mapped.emit(window->id()); break; case CompWindowNotifyUnmap: - WindowManager::window_unmapped.emit(window->id()); + window_unmapped.emit(window->id()); break; case CompWindowNotifyFocusChange: - WindowManager::window_focus_changed.emit(window->id()); + window_focus_changed.emit(window->id()); break; default: break; } } -void -PluginAdapter::NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option) +void PluginAdapter::NotifyCompizEvent(const char* plugin, + const char* event, + CompOption::Vector& option) { if (g_strcmp0(event, "start_viewport_switch") == 0) { _vp_switch_started = true; - compiz_screen_viewport_switch_started.emit(); + screen_viewport_switch_started.emit(); } else if (g_strcmp0(event, "end_viewport_switch") == 0) { _vp_switch_started = false; - compiz_screen_viewport_switch_ended.emit(); + screen_viewport_switch_ended.emit(); } - - compiz_event.emit(plugin, event, option); } -void -MultiActionList::AddNewAction(std::string const& name, CompAction* a, bool primary) +void MultiActionList::AddNewAction(std::string const& name, CompAction* a, bool primary) { actions_[name] = a; @@ -328,13 +323,9 @@ void MultiActionList::TerminateAll(CompOption::Vector const& extra_args) const } } -unsigned long long -PluginAdapter::GetWindowActiveNumber (guint32 xid) const +unsigned long long PluginAdapter::GetWindowActiveNumber(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { @@ -349,33 +340,32 @@ PluginAdapter::GetWindowActiveNumber (guint32 xid) const return 0; } -void -PluginAdapter::SetExpoAction(MultiActionList& expo) +void PluginAdapter::SetExpoAction(MultiActionList& expo) { m_ExpoActionList = expo; } -void -PluginAdapter::SetScaleAction(MultiActionList& scale) +void PluginAdapter::SetScaleAction(MultiActionList& scale) { m_ScaleActionList = scale; } -std::string -PluginAdapter::MatchStringForXids(std::vector<Window> const& windows) +std::string PluginAdapter::MatchStringForXids(std::vector<Window> const& windows) { - std::string out_string = "any & ("; + std::ostringstream sout; - for (auto const& xid : windows) - out_string += "| xid=" + std::to_string(xid) + " "; + sout << "any & ("; - out_string += ")"; + for (auto const& window : windows) + { + sout << "| xid=" << window << " "; + } + sout << ")"; - return out_string; + return sout.str(); } -void -PluginAdapter::InitiateScale(std::string const& match, int state) +void PluginAdapter::InitiateScale(std::string const& match, int state) { CompOption::Vector argument(1); argument[0].setName("match", CompOption::TypeMatch); @@ -384,32 +374,27 @@ PluginAdapter::InitiateScale(std::string const& match, int state) m_ScaleActionList.InitiateAll(argument, state); } -void -PluginAdapter::TerminateScale() +void PluginAdapter::TerminateScale() { m_ScaleActionList.TerminateAll(); } -bool -PluginAdapter::IsScaleActive() const +bool PluginAdapter::IsScaleActive() const { return m_Screen->grabExist("scale"); } -bool -PluginAdapter::IsScaleActiveForGroup() const +bool PluginAdapter::IsScaleActiveForGroup() const { return _spread_windows_state && m_Screen->grabExist("scale"); } -bool -PluginAdapter::IsExpoActive() const +bool PluginAdapter::IsExpoActive() const { return m_Screen->grabExist("expo"); } -bool -PluginAdapter::IsWallActive() const +bool PluginAdapter::IsWallActive() const { return m_Screen->grabExist("wall"); } @@ -425,19 +410,14 @@ void PluginAdapter::TerminateExpo() } // WindowManager implementation -guint32 -PluginAdapter::GetActiveWindow() const +Window PluginAdapter::GetActiveWindow() const { return m_Screen->activeWindow(); } -bool -PluginAdapter::IsWindowMaximized(guint xid) const +bool PluginAdapter::IsWindowMaximized(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { return ((window->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE); @@ -446,12 +426,9 @@ PluginAdapter::IsWindowMaximized(guint xid) const return false; } -bool -PluginAdapter::IsWindowDecorated(guint32 xid) +bool PluginAdapter::IsWindowDecorated(Window window_id) const { Display* display = m_Screen->dpy(); - Window win = xid; - Atom hints_atom = None; MotifWmHints* hints = NULL; Atom type = None; gint format; @@ -459,9 +436,9 @@ PluginAdapter::IsWindowDecorated(guint32 xid) gulong bytes_after; bool ret = true; - hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false); + Atom hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false); - if (XGetWindowProperty(display, win, hints_atom, 0, + if (XGetWindowProperty(display, window_id, hints_atom, 0, sizeof(MotifWmHints) / sizeof(long), False, hints_atom, &type, &format, &nitems, &bytes_after, (guchar**)&hints) != Success) @@ -477,22 +454,20 @@ PluginAdapter::IsWindowDecorated(guint32 xid) hints->flags & MWM_HINTS_DECORATIONS) { /* Must have both bits set */ - _window_decoration_state[xid] = ret = - (hints->decorations & (MwmDecorAll | MwmDecorTitle)) || + ret = (hints->decorations & (MwmDecorAll | MwmDecorTitle)) || (hints->decorations & MWM_HINTS_UNDECORATED_UNITY); + // This is mildly evil and we should look for another solution. + PluginAdapter* non_const_this = const_cast<PluginAdapter*>(this); + non_const_this->_window_decoration_state[window_id] = ret; } XFree(hints); return ret; } -bool -PluginAdapter::IsWindowOnCurrentDesktop(guint32 xid) const +bool PluginAdapter::IsWindowOnCurrentDesktop(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { // we aren't checking window->onCurrentDesktop (), as the name implies, because that is broken @@ -502,13 +477,9 @@ PluginAdapter::IsWindowOnCurrentDesktop(guint32 xid) const return false; } -bool -PluginAdapter::IsWindowObscured(guint32 xid) const +bool PluginAdapter::IsWindowObscured(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { @@ -535,35 +506,26 @@ PluginAdapter::IsWindowObscured(guint32 xid) const return false; } -bool -PluginAdapter::IsWindowMapped(guint32 xid) const +bool PluginAdapter::IsWindowMapped(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) return window->mapNum () > 0; return true; } -bool -PluginAdapter::IsWindowVisible(guint32 xid) const +bool PluginAdapter::IsWindowVisible(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) return !(window->state() & CompWindowStateHiddenMask) && !window->inShowDesktopMode(); return false; } -bool -PluginAdapter::IsWindowOnTop(guint32 xid) const +bool PluginAdapter::IsWindowOnTop(Window window_id) const { - if (xid == GetTopMostValidWindowInViewport()) + if (window_id == GetTopMostValidWindowInViewport()) return true; return false; @@ -594,130 +556,91 @@ Window PluginAdapter::GetTopMostValidWindowInViewport() const return 0; } -bool -PluginAdapter::IsWindowClosable(guint32 xid) const +bool PluginAdapter::IsWindowClosable(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) return (window->actions() & CompWindowActionCloseMask); return false; } -bool -PluginAdapter::IsWindowMinimizable(guint32 xid) const +bool PluginAdapter::IsWindowMinimizable(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) return (window->actions() & CompWindowActionMinimizeMask); return false; } -bool -PluginAdapter::IsWindowMaximizable(guint32 xid) const +bool PluginAdapter::IsWindowMaximizable(Window window_id) const { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) return (window->actions() & MAXIMIZABLE); return false; } -void -PluginAdapter::Restore(guint32 xid) +void PluginAdapter::Restore(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) window->maximize(0); } -void -PluginAdapter::RestoreAt(guint32 xid, int x, int y) +void PluginAdapter::RestoreAt(Window window_id, int x, int y) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window && (window->state() & MAXIMIZE_STATE)) { - nux::Geometry new_geo(GetWindowSavedGeometry(xid)); + nux::Geometry new_geo(GetWindowSavedGeometry(window_id)); new_geo.x = x; new_geo.y = y; window->maximize(0); - MoveResizeWindow(xid, new_geo); + MoveResizeWindow(window_id, new_geo); } } -void -PluginAdapter::Minimize(guint32 xid) +void PluginAdapter::Minimize(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window && (window->actions() & CompWindowActionMinimizeMask)) window->minimize(); } -void -PluginAdapter::Close(guint32 xid) +void PluginAdapter::Close(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) window->close(CurrentTime); } -void -PluginAdapter::Activate(guint32 xid) +void PluginAdapter::Activate(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) window->activate(); } -void -PluginAdapter::Raise(guint32 xid) +void PluginAdapter::Raise(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) window->raise(); } -void -PluginAdapter::Lower(guint32 xid) +void PluginAdapter::Lower(Window window_id) { - Window win = xid; - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) window->lower(); } -void -PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility, int monitor, bool only_top_win) +void PluginAdapter::FocusWindowGroup(std::vector<Window> const& window_ids, + FocusVisibility focus_visibility, + int monitor, bool only_top_win) { CompPoint target_vp = m_Screen->vp(); CompWindow* top_window = nullptr; @@ -838,8 +761,7 @@ PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility } } -bool -PluginAdapter::ScaleWindowGroup(std::vector<Window> windows, int state, bool force) +bool PluginAdapter::ScaleWindowGroup(std::vector<Window> const& windows, int state, bool force) { std::size_t num_windows = windows.size(); if (num_windows > 1 || (force && num_windows)) @@ -852,8 +774,7 @@ PluginAdapter::ScaleWindowGroup(std::vector<Window> windows, int state, bool for return false; } -void -PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo) +void PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo) { long data[4]; @@ -867,8 +788,7 @@ PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo) (unsigned char*) data, 4); } -void -PluginAdapter::ShowDesktop() +void PluginAdapter::ShowDesktop() { if (_in_show_desktop) { @@ -887,25 +807,22 @@ bool PluginAdapter::InShowDesktop() const return _in_show_desktop; } -void -PluginAdapter::OnShowDesktop() +void PluginAdapter::OnShowDesktop() { LOG_DEBUG(logger) << "Now in show desktop mode."; _in_show_desktop = true; } -void -PluginAdapter::OnLeaveDesktop() +void PluginAdapter::OnLeaveDesktop() { LOG_DEBUG(logger) << "No longer in show desktop mode."; _in_show_desktop = false; } -int -PluginAdapter::GetWindowMonitor(guint32 xid) const +int PluginAdapter::GetWindowMonitor(Window window_id) const { // FIXME, we should use window->outputDevice() but this is not UScreen friendly - nux::Geometry const& geo = GetWindowGeometry(xid); + nux::Geometry const& geo = GetWindowGeometry(window_id); if (!geo.IsNull()) { @@ -918,14 +835,10 @@ PluginAdapter::GetWindowMonitor(guint32 xid) const return -1; } -nux::Geometry -PluginAdapter::GetWindowGeometry(guint32 xid) const +nux::Geometry PluginAdapter::GetWindowGeometry(Window window_id) const { - Window win = xid; - CompWindow* window; nux::Geometry geo; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { geo.x = window->borderRect().x(); @@ -936,14 +849,10 @@ PluginAdapter::GetWindowGeometry(guint32 xid) const return geo; } -nux::Geometry -PluginAdapter::GetWindowSavedGeometry(guint32 xid) const +nux::Geometry PluginAdapter::GetWindowSavedGeometry(Window window_id) const { - Window win = xid; nux::Geometry geo(0, 0, 1, 1); - CompWindow* window; - - window = m_Screen->findWindow(win); + CompWindow* window = m_Screen->findWindow(window_id); if (window) { XWindowChanges &wc = window->saveWc(); @@ -956,37 +865,27 @@ PluginAdapter::GetWindowSavedGeometry(guint32 xid) const return geo; } -nux::Geometry -PluginAdapter::GetScreenGeometry() const +nux::Geometry PluginAdapter::GetScreenGeometry() const { - nux::Geometry geo; - - geo.x = 0; - geo.y = 0; - geo.width = m_Screen->width(); - geo.height = m_Screen->height(); - + nux::Geometry geo(0, 0, m_Screen->width(), m_Screen->height()); return geo; } -nux::Geometry -PluginAdapter::GetWorkAreaGeometry(guint32 xid) const +nux::Geometry PluginAdapter::GetWorkAreaGeometry(Window window_id) const { CompWindow* window = nullptr; unsigned int output = 0; - if (xid != 0) + if (window_id) { - Window win = xid; - - window = m_Screen->findWindow(win); + window = m_Screen->findWindow(window_id); if (window) { output = window->outputDevice(); } } - if (xid == 0 || !window) + if (window_id == 0 || !window) { output = m_Screen->currentOutputDev().id(); } @@ -996,8 +895,7 @@ PluginAdapter::GetWorkAreaGeometry(guint32 xid) const return nux::Geometry(workarea.x(), workarea.y(), workarea.width(), workarea.height()); } -bool -PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* window) const +bool PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* window) const { int intersect_types = CompWindowTypeNormalMask | CompWindowTypeDialogMask | CompWindowTypeModalDialogMask | CompWindowTypeUtilMask; @@ -1015,8 +913,7 @@ PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* return false; } -void -PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) +void PluginAdapter::CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any) { // prime to false so we can assume values later one active = false; @@ -1053,14 +950,12 @@ PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &acti } } -int -PluginAdapter::WorkspaceCount() const +int PluginAdapter::WorkspaceCount() const { return m_Screen->vpSize().width() * m_Screen->vpSize().height(); } -void -PluginAdapter::SetMwmWindowHints(Window xid, MotifWmHints* new_hints) +void PluginAdapter::SetMwmWindowHints(Window xid, MotifWmHints* new_hints) { Display* display = m_Screen->dpy(); Atom hints_atom = None; @@ -1111,19 +1006,17 @@ PluginAdapter::SetMwmWindowHints(Window xid, MotifWmHints* new_hints) XFree(data); } -void -PluginAdapter::Decorate(guint32 xid) +void PluginAdapter::Decorate(Window window_id) { MotifWmHints hints = { 0 }; hints.flags = MWM_HINTS_DECORATIONS; hints.decorations = GDK_DECOR_ALL & ~(MWM_HINTS_UNDECORATED_UNITY); - SetMwmWindowHints(xid, &hints); + SetMwmWindowHints(window_id, &hints); } -void -PluginAdapter::Undecorate(guint32 xid) +void PluginAdapter::Undecorate(Window window_id) { MotifWmHints hints = { 0 }; @@ -1133,17 +1026,15 @@ PluginAdapter::Undecorate(guint32 xid) hints.flags = MWM_HINTS_DECORATIONS; hints.decorations = MWM_HINTS_UNDECORATED_UNITY; - SetMwmWindowHints(xid, &hints); + SetMwmWindowHints(window_id, &hints); } -bool -PluginAdapter::IsScreenGrabbed() const +bool PluginAdapter::IsScreenGrabbed() const { return m_Screen->grabbed(); } -bool -PluginAdapter::IsViewPortSwitchStarted() const +bool PluginAdapter::IsViewPortSwitchStarted() const { return _vp_switch_started; } @@ -1208,8 +1099,7 @@ bool PluginAdapter::MaximizeIfBigEnough(CompWindow* window) const return true; } -void -PluginAdapter::ShowGrabHandles(CompWindow* window, bool use_timer) +void PluginAdapter::ShowGrabHandles(CompWindow* window, bool use_timer) { if (!_grab_show_action || !window) return; @@ -1226,8 +1116,7 @@ PluginAdapter::ShowGrabHandles(CompWindow* window, bool use_timer) _grab_show_action->initiate()(_grab_show_action, 0, argument); } -void -PluginAdapter::HideGrabHandles(CompWindow* window) +void PluginAdapter::HideGrabHandles(CompWindow* window) { if (!_grab_hide_action || !window) return; @@ -1242,8 +1131,7 @@ PluginAdapter::HideGrabHandles(CompWindow* window) _grab_hide_action->initiate()(_grab_hide_action, 0, argument); } -void -PluginAdapter::ToggleGrabHandles(CompWindow* window) +void PluginAdapter::ToggleGrabHandles(CompWindow* window) { if (!_grab_toggle_action || !window) return; @@ -1258,14 +1146,12 @@ PluginAdapter::ToggleGrabHandles(CompWindow* window) _grab_toggle_action->initiate()(_grab_toggle_action, 0, argument); } -void -PluginAdapter::SetCoverageAreaBeforeAutomaximize(float area) +void PluginAdapter::SetCoverageAreaBeforeAutomaximize(float area) { _coverage_area_before_automaximize = area; } -bool -PluginAdapter::saveInputFocus() +bool PluginAdapter::SaveInputFocus() { Window active = m_Screen->activeWindow (); CompWindow* cw = m_Screen->findWindow (active); @@ -1279,8 +1165,7 @@ PluginAdapter::saveInputFocus() return false; } -bool -PluginAdapter::restoreInputFocus() +bool PluginAdapter::RestoreInputFocus() { if (_last_focused_window) { @@ -1297,11 +1182,10 @@ PluginAdapter::restoreInputFocus() return false; } -void -PluginAdapter::MoveResizeWindow(guint32 xid, nux::Geometry geometry) +void PluginAdapter::MoveResizeWindow(Window window_id, nux::Geometry geometry) { int w, h; - CompWindow* window = m_Screen->findWindow(xid); + CompWindow* window = m_Screen->findWindow(window_id); if (!window) return; @@ -1333,15 +1217,13 @@ PluginAdapter::MoveResizeWindow(guint32 xid, nux::Geometry geometry) window->configureXWindow(CWX | CWY | CWWidth | CWHeight, &xwc); } -void -PluginAdapter::OnWindowClosed(CompWindow *w) +void PluginAdapter::OnWindowClosed(CompWindow *w) { if (_last_focused_window == w) _last_focused_window = NULL; } -void -PluginAdapter::AddProperties(GVariantBuilder* builder) +void PluginAdapter::AddProperties(GVariantBuilder* builder) { unity::variant::BuilderWrapper wrapper(builder); wrapper.add(GetScreenGeometry()) @@ -1355,28 +1237,26 @@ PluginAdapter::AddProperties(GVariantBuilder* builder) .add("showdesktop_active", _in_show_desktop); } -std::string -PluginAdapter::GetWindowName(guint32 xid) const +std::string PluginAdapter::GetWindowName(Window window_id) const { std::string name; Atom visibleNameAtom; visibleNameAtom = XInternAtom(m_Screen->dpy(), "_NET_WM_VISIBLE_NAME", 0); - name = GetUtf8Property(xid, visibleNameAtom); + name = GetUtf8Property(window_id, visibleNameAtom); if (name.empty()) { Atom wmNameAtom = XInternAtom(m_Screen->dpy(), "_NET_WM_NAME", 0); - name = GetUtf8Property(xid, wmNameAtom); + name = GetUtf8Property(window_id, wmNameAtom); } if (name.empty()) - name = GetTextProperty(xid, XA_WM_NAME); + name = GetTextProperty(window_id, XA_WM_NAME); return name; } -std::string -PluginAdapter::GetUtf8Property(guint32 xid, Atom atom) const +std::string PluginAdapter::GetUtf8Property(Window window_id, Atom atom) const { Atom type; int result, format; @@ -1386,7 +1266,7 @@ PluginAdapter::GetUtf8Property(guint32 xid, Atom atom) const Atom utf8StringAtom; utf8StringAtom = XInternAtom(m_Screen->dpy(), "UTF8_STRING", 0); - result = XGetWindowProperty(m_Screen->dpy(), xid, atom, 0L, 65536, False, + result = XGetWindowProperty(m_Screen->dpy(), window_id, atom, 0L, 65536, False, utf8StringAtom, &type, &format, &nItems, &bytesAfter, reinterpret_cast<unsigned char **>(&val)); @@ -1403,21 +1283,22 @@ PluginAdapter::GetUtf8Property(guint32 xid, Atom atom) const return retval; } -std::string -PluginAdapter::GetTextProperty(guint32 id, Atom atom) const +std::string PluginAdapter::GetTextProperty(Window window_id, Atom atom) const { XTextProperty text; std::string retval; text.nitems = 0; - if (XGetTextProperty(m_Screen->dpy(), id, &text, atom)) + if (XGetTextProperty(m_Screen->dpy(), window_id, &text, atom)) { if (text.value) { retval = std::string(reinterpret_cast<char*>(text.value), text.nitems); - XFree (text.value); + XFree(text.value); } } return retval; } + +} diff --git a/unity-shared/PluginAdapter.h b/unity-shared/PluginAdapter.h index 06ce7ef33..8f09bf3f7 100644 --- a/unity-shared/PluginAdapter.h +++ b/unity-shared/PluginAdapter.h @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -17,16 +17,19 @@ * Authored by: Jason Smith <jason.smith@canonical.com> */ -#ifndef PLUGINADAPTER_H -#define PLUGINADAPTER_H +#ifndef UNITYSHARED_PLUGINADAPTER_H +#define UNITYSHARED_PLUGINADAPTER_H /* Compiz */ #include <core/core.h> #include <core/atoms.h> -#include <sigc++/sigc++.h> +#include <NuxCore/Property.h> -#include "WindowManager.h" +#include "XWindowManager.h" + +namespace unity +{ typedef struct { @@ -60,11 +63,12 @@ private: }; -class PluginAdapter : public sigc::trackable, public WindowManager +class PluginAdapter : public sigc::trackable, public XWindowManager { public: - static PluginAdapter* Default(); - + // You shouldn't get the PluginAdapter if you really want a WindowManager. + // The PluginAdapter::Default should really only be called from within unityshell plugin. + static PluginAdapter& Default(); static void Initialize(CompScreen* screen); nux::Property<bool> bias_active_to_viewport; @@ -113,54 +117,56 @@ public: void NotifyResized(CompWindow* window, int x, int y, int w, int h); void NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state); void NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option); - void NotifyNewDecorationState(guint32 xid); + void NotifyNewDecorationState(Window xid); - guint32 GetActiveWindow() const; + Window GetActiveWindow() const; - void Decorate(guint32 xid); - void Undecorate(guint32 xid); + void Decorate(Window xid); + void Undecorate(Window xid); // WindowManager implementation - bool IsWindowMaximized(guint xid) const; - bool IsWindowDecorated(guint xid); - bool IsWindowOnCurrentDesktop(guint xid) const; - bool IsWindowObscured(guint xid) const; - bool IsWindowMapped(guint xid) const; - bool IsWindowVisible(guint32 xid) const; - bool IsWindowOnTop(guint32 xid) const; - bool IsWindowClosable(guint32 xid) const; - bool IsWindowMinimizable(guint32 xid) const; - bool IsWindowMaximizable(guint32 xid) const; - - void Restore(guint32 xid); - void RestoreAt(guint32 xid, int x, int y); - void Minimize(guint32 xid); - void Close(guint32 xid); - void Activate(guint32 xid); - void Raise(guint32 xid); - void Lower(guint32 xid); + bool IsWindowMaximized(Window window_id) const; + bool IsWindowDecorated(Window window_id) const; + bool IsWindowOnCurrentDesktop(Window window_id) const; + bool IsWindowObscured(Window window_id) const; + bool IsWindowMapped(Window window_id) const; + bool IsWindowVisible(Window window_id) const; + bool IsWindowOnTop(Window window_id) const; + bool IsWindowClosable(Window window_id) const; + bool IsWindowMinimizable(Window window_id) const; + bool IsWindowMaximizable(Window window_id) const; + + void Restore(Window window_id); + void RestoreAt(Window window_id, int x, int y); + void Minimize(Window window_id); + void Close(Window window_id); + void Activate(Window window_id); + void Raise(Window window_id); + void Lower(Window window_id); void ShowDesktop(); bool InShowDesktop() const; void SetWindowIconGeometry(Window window, nux::Geometry const& geo); - void FocusWindowGroup(std::vector<Window> windows, FocusVisibility, int monitor = -1, bool only_top_win = true); - bool ScaleWindowGroup(std::vector<Window> windows, int state, bool force); + void FocusWindowGroup(std::vector<Window> const& windows, + FocusVisibility, int monitor = -1, bool only_top_win = true); + bool ScaleWindowGroup(std::vector<Window> const& windows, + int state, bool force); bool IsScreenGrabbed() const; bool IsViewPortSwitchStarted() const; - unsigned long long GetWindowActiveNumber (guint32 xid) const; + unsigned long long GetWindowActiveNumber(Window window_id) const; bool MaximizeIfBigEnough(CompWindow* window) const; - int GetWindowMonitor(guint32 xid) const; - nux::Geometry GetWindowGeometry(guint32 xid) const; - nux::Geometry GetWindowSavedGeometry(guint32 xid) const; + int GetWindowMonitor(Window window_id) const; + nux::Geometry GetWindowGeometry(Window window_id) const; + nux::Geometry GetWindowSavedGeometry(Window window_id) const; nux::Geometry GetScreenGeometry() const; - nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const; - std::string GetWindowName(guint32 xid) const; + nux::Geometry GetWorkAreaGeometry(Window window_id = 0) const; + std::string GetWindowName(Window window_id) const; void CheckWindowIntersections(nux::Geometry const& region, bool &active, bool &any); @@ -168,10 +174,10 @@ public: void SetCoverageAreaBeforeAutomaximize(float area); - bool saveInputFocus (); - bool restoreInputFocus (); + bool SaveInputFocus(); + bool RestoreInputFocus(); - void MoveResizeWindow(guint32 xid, nux::Geometry geometry); + void MoveResizeWindow(Window window_id, nux::Geometry geometry); protected: PluginAdapter(CompScreen* screen); @@ -186,8 +192,8 @@ private: Window GetTopMostValidWindowInViewport() const; - std::string GetTextProperty(guint32 xid, Atom atom) const; - std::string GetUtf8Property(guint32 xid, Atom atom) const; + std::string GetTextProperty(Window xid, Atom atom) const; + std::string GetUtf8Property(Window xid, Atom atom) const; CompScreen* m_Screen; MultiActionList m_ExpoActionList; @@ -207,9 +213,9 @@ private: bool _in_show_desktop; CompWindow* _last_focused_window; - std::map<guint32, unsigned int> _window_decoration_state; - - static PluginAdapter* _default; + std::map<Window, unsigned int> _window_decoration_state; }; +} + #endif diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp deleted file mode 100644 index b457c57d6..000000000 --- a/unity-shared/PluginAdapterStandalone.cpp +++ /dev/null @@ -1,491 +0,0 @@ -// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- -/* - * Copyright (C) 2010 Canonical Ltd - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Authored by: Jason Smith <jason.smith@canonical.com> - */ - -#include <glib.h> -#include <sstream> -#include "PluginAdapter.h" -#include "UScreen.h" - -#include <NuxCore/Logger.h> -#include <UnityCore/Variant.h> - -//FIXME!! Entirely stubs for now, unless we need this functionality at some point - -namespace -{ -nux::logging::Logger logger("unity.plugin"); -} - -PluginAdapter* PluginAdapter::_default = 0; - -/* static */ -PluginAdapter* -PluginAdapter::Default() -{ - if (!_default) - return 0; - return _default; -} - -/* static */ -void -PluginAdapter::Initialize(CompScreen* screen) -{ - _default = new PluginAdapter(screen); -} - -PluginAdapter::PluginAdapter(CompScreen* screen) - : m_Screen(screen) - , _expo_state(false) - , _in_show_desktop(false) - , _last_focused_window(nullptr) -{ -} - -PluginAdapter::~PluginAdapter() -{ -} - -/* A No-op for now, but could be useful later */ -void -PluginAdapter::OnScreenGrabbed() -{ -} - -void -PluginAdapter::OnScreenUngrabbed() -{ -} - -void -PluginAdapter::NotifyResized(CompWindow* window, int x, int y, int w, int h) -{ -} - -void -PluginAdapter::NotifyMoved(CompWindow* window, int x, int y) -{ -} - -void -PluginAdapter::NotifyStateChange(CompWindow* window, unsigned int state, unsigned int last_state) -{ -} - -void -PluginAdapter::NotifyNewDecorationState(guint32 xid) -{ -} - -void -PluginAdapter::Notify(CompWindow* window, CompWindowNotify notify) -{ -} - -void -PluginAdapter::NotifyCompizEvent(const char* plugin, const char* event, CompOption::Vector& option) -{ -} - -void -MultiActionList::AddNewAction(std::string const& n, CompAction* a, bool primary) -{ -} - -void -MultiActionList::RemoveAction(std::string const& n) -{ -} - -void -MultiActionList::InitiateAll(CompOption::Vector const& extraArgs, int state) const -{ -} - -void -MultiActionList::TerminateAll(CompOption::Vector const& extraArgs) const -{ -} - -bool -MultiActionList::HasPrimary() const -{ - return false; -} - -CompAction* -MultiActionList::GetAction(std::string const& name) const -{ - return nullptr; -} - - -unsigned long long -PluginAdapter::GetWindowActiveNumber (guint32 xid) const -{ - return 0; -} - -void -PluginAdapter::SetExpoAction(MultiActionList& expo) -{ -} - -void -PluginAdapter::SetScaleAction(MultiActionList& scale) -{ -} - -std::string -PluginAdapter::MatchStringForXids(std::vector<Window> const& windows) -{ - return ""; -} - -void -PluginAdapter::InitiateScale(std::string const& match, int state) -{ -} - -void -PluginAdapter::TerminateScale() -{ -} - -bool -PluginAdapter::IsScaleActive() const -{ - return false; -} - -bool -PluginAdapter::IsScaleActiveForGroup() const -{ - return false; -} - -bool -PluginAdapter::IsExpoActive() const -{ - return _expo_state; -} - -void -PluginAdapter::InitiateExpo() -{ - _expo_state = true; -} - -void -PluginAdapter::TerminateExpo() -{ - _expo_state = false; -} - -bool -PluginAdapter::IsWallActive() const -{ - return false; -} - -// WindowManager implementation -guint32 -PluginAdapter::GetActiveWindow() const -{ - return 0; -} - -bool -PluginAdapter::IsWindowMaximized(guint xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowDecorated(guint32 xid) -{ - return false; -} - -bool -PluginAdapter::IsWindowOnCurrentDesktop(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowObscured(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowMapped(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowVisible(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowOnTop(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowClosable(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowMinimizable(guint32 xid) const -{ - return false; -} - -bool -PluginAdapter::IsWindowMaximizable(guint32 xid) const -{ - return false; -} - -void -PluginAdapter::Restore(guint32 xid) -{ -} - -void -PluginAdapter::RestoreAt(guint32 xid, int x, int y) -{ -} - -void -PluginAdapter::Minimize(guint32 xid) -{ -} - -void -PluginAdapter::Close(guint32 xid) -{ -} - -void -PluginAdapter::Activate(guint32 xid) -{ -} - -void -PluginAdapter::Raise(guint32 xid) -{ -} - -void -PluginAdapter::Lower(guint32 xid) -{ -} - -void -PluginAdapter::FocusWindowGroup(std::vector<Window> window_ids, FocusVisibility focus_visibility, int monitor, bool only_top_win) -{ -} - -bool -PluginAdapter::ScaleWindowGroup(std::vector<Window> windows, int state, bool force) -{ - return false; -} - -void -PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo) -{ -} - -void -PluginAdapter::ShowDesktop() -{ - _in_show_desktop = !_in_show_desktop; -} - -bool PluginAdapter::InShowDesktop() const -{ - return _in_show_desktop; -} - -void -PluginAdapter::OnShowDesktop() -{ -} - -void -PluginAdapter::OnLeaveDesktop() -{ -} - -int -PluginAdapter::GetWindowMonitor(guint32 xid) const -{ - return -1; -} - -nux::Geometry -PluginAdapter::GetWindowGeometry(guint32 xid) const -{ - nux::Geometry geo(0, 0, 1, 1); - return geo; -} - -nux::Geometry -PluginAdapter::GetWindowSavedGeometry(guint32 xid) const -{ - nux::Geometry geo(0, 0, 1, 1); - return geo; -} - -nux::Geometry -PluginAdapter::GetScreenGeometry() const -{ - nux::Geometry geo(0, 0, 1, 1); - return geo; -} - -nux::Geometry -PluginAdapter::GetWorkAreaGeometry(guint32 xid) const -{ - nux::Geometry geo(0, 0, 1, 1); - return geo; -} - -bool -PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* window) const -{ - return false; -} - -void -PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) -{ -} - -int -PluginAdapter::WorkspaceCount() const -{ - return 4; -} - -void -PluginAdapter::SetMwmWindowHints(Window xid, MotifWmHints* new_hints) -{ -} - -void -PluginAdapter::Decorate(guint32 xid) -{ -} - -void -PluginAdapter::Undecorate(guint32 xid) -{ -} - -bool -PluginAdapter::IsScreenGrabbed() const -{ - return false; -} - -bool -PluginAdapter::IsViewPortSwitchStarted() const -{ - return false; -} - -/* Returns true if the window was maximized */ -bool PluginAdapter::MaximizeIfBigEnough(CompWindow* window) const -{ - return true; -} - -void -PluginAdapter::ShowGrabHandles(CompWindow* window, bool use_timer) -{ -} - -void -PluginAdapter::HideGrabHandles(CompWindow* window) -{ -} - -void -PluginAdapter::ToggleGrabHandles(CompWindow* window) -{ -} - -void -PluginAdapter::SetCoverageAreaBeforeAutomaximize(float area) -{ -} - -bool -PluginAdapter::saveInputFocus() -{ - return false; -} - -bool -PluginAdapter::restoreInputFocus() -{ - return false; -} - -void -PluginAdapter::MoveResizeWindow(guint32 xid, nux::Geometry geometry) -{ -} - -void -PluginAdapter::OnWindowClosed(CompWindow *w) -{ -} - -void -PluginAdapter::AddProperties(GVariantBuilder* builder) -{ - unity::variant::BuilderWrapper wrapper(builder); - wrapper.add(GetScreenGeometry()) - .add("workspace_count", WorkspaceCount()) - .add("active_window", GetActiveWindow()) - .add("screen_grabbed", IsScreenGrabbed()) - .add("scale_active", IsScaleActive()) - .add("scale_active_for_group", IsScaleActiveForGroup()) - .add("expo_active", IsExpoActive()) - .add("viewport_switch_running", IsViewPortSwitchStarted()) - .add("showdesktop_active", _in_show_desktop); -} - -std::string -PluginAdapter::GetWindowName(guint32 xid) const -{ - return ""; -} diff --git a/unity-shared/StandaloneWindowManager.cpp b/unity-shared/StandaloneWindowManager.cpp new file mode 100644 index 000000000..bc3902c25 --- /dev/null +++ b/unity-shared/StandaloneWindowManager.cpp @@ -0,0 +1,274 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2010-2012 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Jason Smith <jason.smith@canonical.com> + * Tim Penhey <tim.penhey@canonical.com> + */ + +#include <glib.h> +#include <sstream> +#include "StandaloneWindowManager.h" +#include "UScreen.h" + +#include <NuxCore/Logger.h> +#include <UnityCore/Variant.h> + +// Entirely stubs for now, unless we need this functionality at some point + +namespace unity +{ + +namespace +{ +nux::logging::Logger logger("unity.wm"); +} + +WindowManagerPtr create_window_manager() +{ + return WindowManagerPtr(new StandaloneWindowManager); +} + +StandaloneWindowManager::StandaloneWindowManager() + : expo_state_(false) + , in_show_desktop_(false) +{ +} + +Window StandaloneWindowManager::GetActiveWindow() const +{ + return 0; +} + +bool StandaloneWindowManager::IsWindowMaximized(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowDecorated(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowOnCurrentDesktop(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowObscured(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowMapped(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowVisible(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowOnTop(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowClosable(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowMinimizable(Window window_id) const +{ + return false; +} + +bool StandaloneWindowManager::IsWindowMaximizable(Window window_id) const +{ + return false; +} + +void StandaloneWindowManager::ShowDesktop() +{ + in_show_desktop_ = !in_show_desktop_; +} + +bool StandaloneWindowManager::InShowDesktop() const +{ + return in_show_desktop_; +} + +void StandaloneWindowManager::Restore(Window window_id) +{} + +void StandaloneWindowManager::RestoreAt(Window window_id, int x, int y) +{} + +void StandaloneWindowManager::Minimize(Window window_id) +{} + +void StandaloneWindowManager::Close(Window window_id) +{} + +void StandaloneWindowManager::Activate(Window window_id) +{} + +void StandaloneWindowManager::Raise(Window window_id) +{} + +void StandaloneWindowManager::Lower(Window window_id) +{} + +void StandaloneWindowManager::TerminateScale() +{} + +bool StandaloneWindowManager::IsScaleActive() const +{ + return false; +} + +bool StandaloneWindowManager::IsScaleActiveForGroup() const +{ + return false; +} + +void StandaloneWindowManager::InitiateExpo() +{ + expo_state_ = !expo_state_; +} + +void StandaloneWindowManager::TerminateExpo() +{ + expo_state_ = false; +} + +bool StandaloneWindowManager::IsExpoActive() const +{ + return expo_state_; +} + +bool StandaloneWindowManager::IsWallActive() const +{ + return false; +} + +void StandaloneWindowManager::FocusWindowGroup(std::vector<Window> const& windows, + FocusVisibility, + int monitor, + bool only_top_win) +{} + +bool StandaloneWindowManager::ScaleWindowGroup(std::vector<Window> const& windows, + int state, bool force) +{ + return false; +} + +bool StandaloneWindowManager::IsScreenGrabbed() const +{ + return false; +} + +bool StandaloneWindowManager::IsViewPortSwitchStarted() const +{ + return false; +} + +void StandaloneWindowManager::MoveResizeWindow(Window window_id, nux::Geometry geometry) +{} + +void StandaloneWindowManager::StartMove(Window window_id, int x, int y) +{} + +int StandaloneWindowManager::GetWindowMonitor(Window window_id) const +{ + return -1; +} + +nux::Geometry StandaloneWindowManager::GetWindowGeometry(Window window_id) const +{ + nux::Geometry geo(0, 0, 1, 1); + return geo; +} + +nux::Geometry StandaloneWindowManager::GetWindowSavedGeometry(Window window_id) const +{ + nux::Geometry geo(0, 0, 1, 1); + return geo; +} + +nux::Geometry StandaloneWindowManager::GetScreenGeometry() const +{ + nux::Geometry geo(0, 0, 1, 1); + return geo; +} + +nux::Geometry StandaloneWindowManager::GetWorkAreaGeometry(Window window_id) const +{ + nux::Geometry geo(0, 0, 1, 1); + return geo; +} + +unsigned long long StandaloneWindowManager::GetWindowActiveNumber(Window window_id) const +{ + return 0; +} + +void StandaloneWindowManager::SetWindowIconGeometry(Window window, nux::Geometry const& geo) +{ +} + +void StandaloneWindowManager::CheckWindowIntersections(nux::Geometry const& region, + bool &active, bool &any) +{ +} + +int StandaloneWindowManager::WorkspaceCount() const +{ + return 4; +} + +bool StandaloneWindowManager::SaveInputFocus() +{ + return false; +} + +bool StandaloneWindowManager::RestoreInputFocus() +{ + return false; +} + +std::string StandaloneWindowManager::GetWindowName(Window window_id) const +{ + return ""; +} + +void StandaloneWindowManager::AddProperties(GVariantBuilder* builder) +{ + unity::variant::BuilderWrapper wrapper(builder); + wrapper.add(GetScreenGeometry()) + .add("workspace_count", WorkspaceCount()) + .add("active_window", GetActiveWindow()) + .add("screen_grabbed", IsScreenGrabbed()) + .add("scale_active", IsScaleActive()) + .add("scale_active_for_group", IsScaleActiveForGroup()) + .add("expo_active", IsExpoActive()) + .add("viewport_switch_running", IsViewPortSwitchStarted()) + .add("showdesktop_active", in_show_desktop_); +} + +} // namespace unity diff --git a/unity-shared/StandaloneWindowManager.h b/unity-shared/StandaloneWindowManager.h new file mode 100644 index 000000000..636e3c580 --- /dev/null +++ b/unity-shared/StandaloneWindowManager.h @@ -0,0 +1,108 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* + * Copyright (C) 2012 Canonical Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * Authored by: Tim Penhey <tim.penhey@canonical.com> + */ + +#ifndef UNITYSHARED_STANDALONE_WINDOW_MANAGER_H +#define UNITYSHARED_STANDALONE_WINDOW_MANAGER_H + +#include "unity-shared/WindowManager.h" + +namespace unity +{ + +class StandaloneWindowManager : public WindowManager +{ +public: + StandaloneWindowManager(); + + virtual Window GetActiveWindow() const; + + virtual bool IsWindowMaximized(Window window_id) const; + virtual bool IsWindowDecorated(Window window_id) const; + virtual bool IsWindowOnCurrentDesktop(Window window_id) const; + virtual bool IsWindowObscured(Window window_id) const; + virtual bool IsWindowMapped(Window window_id) const; + virtual bool IsWindowVisible(Window window_id) const; + virtual bool IsWindowOnTop(Window window_id) const; + virtual bool IsWindowClosable(Window window_id) const; + virtual bool IsWindowMinimizable(Window window_id) const; + virtual bool IsWindowMaximizable(Window window_id) const; + + virtual void ShowDesktop(); + virtual bool InShowDesktop() const; + + virtual void Restore(Window window_id); + virtual void RestoreAt(Window window_id, int x, int y); + virtual void Minimize(Window window_id); + virtual void Close(Window window_id); + + virtual void Activate(Window window_id); + virtual void Raise(Window window_id); + virtual void Lower(Window window_id); + + virtual void TerminateScale(); + virtual bool IsScaleActive() const; + virtual bool IsScaleActiveForGroup() const; + + virtual void InitiateExpo(); + virtual void TerminateExpo(); + virtual bool IsExpoActive() const; + + virtual bool IsWallActive() const; + + virtual void FocusWindowGroup(std::vector<Window> const& windows, + FocusVisibility, int monitor = -1, bool only_top_win = true); + virtual bool ScaleWindowGroup(std::vector<Window> const& windows, + int state, bool force); + + virtual bool IsScreenGrabbed() const; + virtual bool IsViewPortSwitchStarted() const; + + virtual void MoveResizeWindow(Window window_id, nux::Geometry geometry); + virtual void StartMove(Window window_id, int x, int y); + + virtual int GetWindowMonitor(Window window_id) const; + virtual nux::Geometry GetWindowGeometry(Window window_id) const; + virtual nux::Geometry GetWindowSavedGeometry(Window window_id) const; + virtual nux::Geometry GetScreenGeometry() const; + virtual nux::Geometry GetWorkAreaGeometry(Window window_id) const; + + virtual unsigned long long GetWindowActiveNumber(Window window_id) const; + + virtual void SetWindowIconGeometry(Window window, nux::Geometry const& geo); + + virtual void CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any); + + virtual int WorkspaceCount() const; + + virtual bool SaveInputFocus(); + virtual bool RestoreInputFocus(); + + virtual std::string GetWindowName(Window window_id) const; + +protected: + virtual void AddProperties(GVariantBuilder* builder); + +private: + bool expo_state_; + bool in_show_desktop_; +}; + +} + +#endif // UNITYSHARED_WINDOW_MANAGER_H diff --git a/unity-shared/StaticCairoText.cpp b/unity-shared/StaticCairoText.cpp index 33cea145c..6a036f65f 100644 --- a/unity-shared/StaticCairoText.cpp +++ b/unity-shared/StaticCairoText.cpp @@ -32,10 +32,6 @@ #include <pango/pango.h> #include <pango/pangocairo.h> -#if defined(NUX_OS_LINUX) -#include <X11/Xlib.h> -#endif - #include <UnityCore/GLibWrapper.h> #include "CairoTexture.h" diff --git a/unity-shared/WindowManager.cpp b/unity-shared/WindowManager.cpp index dc09eeeff..a0bdc3f1a 100644 --- a/unity-shared/WindowManager.cpp +++ b/unity-shared/WindowManager.cpp @@ -1,6 +1,6 @@ // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -17,269 +17,16 @@ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> */ -#include "WindowManager.h" +#include "XWindowManager.h" -static WindowManager* window_manager = NULL; -class WindowManagerDummy : public WindowManager +unity::XWindowManager::XWindowManager() + : move_resize_atom_(XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), + "_NET_WM_MOVERESIZE", FALSE)) { - guint32 GetActiveWindow() const - { - return 0; - } - - unsigned long long GetWindowActiveNumber (guint32 xid) const - { - return 0; - } - - bool IsScreenGrabbed() const - { - return false; - } - - bool IsViewPortSwitchStarted() const - { - return false; - } - - void ShowDesktop() - { - g_debug("%s", G_STRFUNC); - } - - bool InShowDesktop() const - { - return false; - } - - bool IsWindowMaximized(guint32 xid) const - { - return false; - } - - bool IsWindowDecorated(guint32 xid) - { - return true; - } - - bool IsWindowOnCurrentDesktop(guint32 xid) const - { - return true; - } - - bool IsWindowObscured(guint32 xid) const - { - return false; - } - - bool IsWindowMapped(guint32 xid) const - { - return true; - } - - bool IsWindowVisible(guint32 xid) const - { - return true; - } - - bool IsWindowOnTop(guint32 xid) const - { - return false; - } - - bool IsWindowClosable(guint32 xid) const - { - return true; - } - - bool IsWindowMinimizable(guint32 xid) const - { - return true; - } - - bool IsWindowMaximizable(guint32 xid) const - { - return true; - } - - void Restore(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void RestoreAt(guint32 xid, int x, int y) - { - g_debug("%s", G_STRFUNC); - } - - void Minimize(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void Close(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void Activate(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void Raise(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void Lower(guint32 xid) - { - g_debug("%s", G_STRFUNC); - } - - void FocusWindowGroup(std::vector<Window> windows, FocusVisibility, int monitor, bool only_top_win) - { - g_debug("%s", G_STRFUNC); - } - - bool ScaleWindowGroup(std::vector<Window> windows, int state, bool force) - { - g_debug("%s", G_STRFUNC); - return false; - } - - int GetWindowMonitor(guint32 xid) const - { - return -1; - } - - nux::Geometry GetWindowGeometry(guint xid) const - { - int width = (guint32)xid >> 16; - int height = (guint32)xid & 0x0000FFFF; - return nux::Geometry(0, 0, width, height); - } - - nux::Geometry GetWindowSavedGeometry(guint xid) const - { - return nux::Geometry(0, 0, 1, 1); - } - - nux::Geometry GetScreenGeometry() const - { - return nux::Geometry(0, 0, 1, 1); - } - - nux::Geometry GetWorkAreaGeometry(guint32 xid) const - { - return nux::Geometry(0, 0, 1, 1); - } - - void SetWindowIconGeometry(Window window, nux::Geometry const& geo) - { - g_debug("%s", G_STRFUNC); - } - - void CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) - { - active = false; - any = false; - } - - int WorkspaceCount () const - { - return 1; - } - - void TerminateScale() - { - g_debug("%s", G_STRFUNC); - } - - bool IsScaleActive() const - { - g_debug("%s", G_STRFUNC); - return false; - } - - bool IsScaleActiveForGroup() const - { - g_debug("%s", G_STRFUNC); - return false; - } - - void InitiateExpo() - { - g_debug("%s", G_STRFUNC); - } - - void TerminateExpo() - { - g_debug("%s", G_STRFUNC); - } - - bool IsExpoActive() const - { - g_debug("%s", G_STRFUNC); - return false; - } - - bool IsWallActive() const - { - g_debug("%s", G_STRFUNC); - return false; - } - - void MoveResizeWindow(guint32 xid, nux::Geometry geometry) - { - g_debug("%s", G_STRFUNC); - } - - bool saveInputFocus() - { - return false; - } - - bool restoreInputFocus() - { - return false; - } - - - void AddProperties(GVariantBuilder* builder) - { - } - - std::string GetWindowName(guint32 xid) const - { - return "unknown"; - } -}; - -WindowManager* -WindowManager::Default() -{ - if (!window_manager) - window_manager = new WindowManagerDummy(); - - return window_manager; -} - -void -WindowManager::SetDefault(WindowManager* manager) -{ - window_manager = manager; -} - -std::string WindowManager::GetName() const -{ - return "WindowManager"; } -#define NET_WM_MOVERESIZE_MOVE 8 - -void WindowManager::StartMove(guint32 xid, int x, int y) +void unity::XWindowManager::StartMove(Window window_id, int x, int y) { if (x < 0 || y < 0) return; @@ -319,10 +66,12 @@ void WindowManager::StartMove(guint32 xid, int x, int y) ev.xclient.serial = 0; ev.xclient.send_event = true; - ev.xclient.window = xid; - ev.xclient.message_type = m_MoveResizeAtom; + ev.xclient.window = window_id; + ev.xclient.message_type = move_resize_atom_; ev.xclient.format = 32; + const long NET_WM_MOVERESIZE_MOVE = 8; + ev.xclient.data.l[0] = x; // x_root ev.xclient.data.l[1] = y; // y_root ev.xclient.data.l[2] = NET_WM_MOVERESIZE_MOVE; //direction diff --git a/unity-shared/WindowManager.h b/unity-shared/WindowManager.h index f014cd19c..6c2f54bab 100644 --- a/unity-shared/WindowManager.h +++ b/unity-shared/WindowManager.h @@ -1,5 +1,6 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- /* - * Copyright (C) 2010 Canonical Ltd + * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -16,141 +17,29 @@ * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> */ -#ifndef WINDOW_MANAGER_H -#define WINDOW_MANAGER_H +#ifndef UNITYSHARED_XWINDOW_MANAGER_H +#define UNITYSHARED_XWINDOW_MANAGER_H #include <Nux/Nux.h> #include <gdk/gdkx.h> #include <core/core.h> -#include "unity-shared/Introspectable.h" +#include "unity-shared/WindowManager.h" -class WindowManager : public unity::debug::Introspectable +namespace unity { - // This is a glue interface that breaks the dependancy of Unity with Compiz - // Basically it has a default implementation that does nothing useful, but - // the idea is that unity.cpp uses SetDefault() early enough in it's - // initialization so the things that require it get a usable implementation +class XWindowManager : public WindowManager +{ public: - WindowManager() : - m_MoveResizeAtom(XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), - "_NET_WM_MOVERESIZE", FALSE)) - { - }; - - enum class FocusVisibility - { - OnlyVisible, - ForceUnminimizeInvisible, - ForceUnminimizeOnCurrentDesktop - }; - - static WindowManager* Default(); - static void SetDefault(WindowManager* manager); - - virtual guint32 GetActiveWindow() const = 0; - - virtual bool IsWindowMaximized(guint32 xid) const = 0; - virtual bool IsWindowDecorated(guint32 xid) = 0; - virtual bool IsWindowOnCurrentDesktop(guint32 xid) const = 0; - virtual bool IsWindowObscured(guint32 xid) const = 0; - virtual bool IsWindowMapped(guint32 xid) const = 0; - virtual bool IsWindowVisible(guint32 xid) const = 0; - virtual bool IsWindowOnTop(guint32 xid) const = 0; - virtual bool IsWindowClosable(guint32 xid) const = 0; - virtual bool IsWindowMinimizable(guint32 xid) const = 0; - virtual bool IsWindowMaximizable(guint32 xid) const = 0; - - virtual void ShowDesktop() = 0; - virtual bool InShowDesktop() const = 0; - - virtual void Restore(guint32 xid) = 0; - virtual void RestoreAt(guint32 xid, int x, int y) = 0; - virtual void Minimize(guint32 xid) = 0; - virtual void Close(guint32 xid) = 0; - - virtual void Activate(guint32 xid) = 0; - virtual void Raise(guint32 xid) = 0; - virtual void Lower(guint32 xid) = 0; - - virtual void TerminateScale() = 0; - virtual bool IsScaleActive() const = 0; - virtual bool IsScaleActiveForGroup() const = 0; - - virtual void InitiateExpo() = 0; - virtual void TerminateExpo() = 0; - virtual bool IsExpoActive() const = 0; - - virtual bool IsWallActive() const = 0; - - virtual void FocusWindowGroup(std::vector<Window> windows, FocusVisibility, int monitor = -1, bool only_top_win = true) = 0; - virtual bool ScaleWindowGroup(std::vector<Window> windows, int state, bool force) = 0; - - virtual void Decorate(guint32 xid) {}; - virtual void Undecorate(guint32 xid) {}; - - virtual bool IsScreenGrabbed() const = 0; - virtual bool IsViewPortSwitchStarted() const = 0; + XWindowManager(); - virtual void MoveResizeWindow(guint32 xid, nux::Geometry geometry) = 0; - void StartMove(guint32 xid, int, int); - - virtual int GetWindowMonitor(guint32 xid) const = 0; - virtual nux::Geometry GetWindowGeometry(guint32 xid) const = 0; - virtual nux::Geometry GetWindowSavedGeometry(guint32 xid) const = 0; - virtual nux::Geometry GetScreenGeometry() const = 0; - virtual nux::Geometry GetWorkAreaGeometry(guint32 xid = 0) const = 0; - - virtual unsigned long long GetWindowActiveNumber(guint32 xid) const = 0; - - virtual void SetWindowIconGeometry(Window window, nux::Geometry const& geo) = 0; - - virtual void CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) = 0; - - virtual int WorkspaceCount() const = 0; - - virtual bool saveInputFocus() = 0; - virtual bool restoreInputFocus() = 0; - - virtual std::string GetWindowName(guint32 xid) const = 0; - - // Signals - sigc::signal<void, guint32> window_mapped; - sigc::signal<void, guint32> window_unmapped; - sigc::signal<void, guint32> window_maximized; - sigc::signal<void, guint32> window_restored; - sigc::signal<void, guint32> window_minimized; - sigc::signal<void, guint32> window_unminimized; - sigc::signal<void, guint32> window_shaded; - sigc::signal<void, guint32> window_unshaded; - sigc::signal<void, guint32> window_shown; - sigc::signal<void, guint32> window_hidden; - sigc::signal<void, guint32> window_resized; - sigc::signal<void, guint32> window_moved; - sigc::signal<void, guint32> window_focus_changed; - sigc::signal<void, guint32> window_decorated; - sigc::signal<void, guint32> window_undecorated; - - sigc::signal<void> initiate_spread; - sigc::signal<void> terminate_spread; - - sigc::signal<void> initiate_expo; - sigc::signal<void> terminate_expo; - - sigc::signal<void> compiz_screen_grabbed; - sigc::signal<void> compiz_screen_ungrabbed; - sigc::signal<void> compiz_screen_viewport_switch_started; - sigc::signal<void> compiz_screen_viewport_switch_ended; - - sigc::signal<void, const char*, const char*, CompOption::Vector&> compiz_event; - -protected: - std::string GetName() const; - virtual void AddProperties(GVariantBuilder* builder) = 0; + virtual void StartMove(Window window_id, int x, int y); private: - Atom m_MoveResizeAtom; + Atom move_resize_atom_; }; +} + #endif // WINDOW_MANAGER_H diff --git a/unity-standalone/StandaloneUnity.cpp b/unity-standalone/StandaloneUnity.cpp index 50069c989..980c583e1 100644 --- a/unity-standalone/StandaloneUnity.cpp +++ b/unity-standalone/StandaloneUnity.cpp @@ -38,7 +38,6 @@ #include "unity-shared/DashStyle.h" #include "unity-shared/FontSettings.h" #include "unity-shared/PanelStyle.h" -#include "unity-shared/PluginAdapter.h" #include "unity-shared/UBusMessages.h" #include "unity-shared/UBusWrapper.h" #include "unity-shared/UnitySettings.h" @@ -161,8 +160,7 @@ int main(int argc, char **argv) Settings settings; settings.is_standalone = true; if (force_tv) Settings::Instance().form_factor(FormFactor::TV); - - PluginAdapter::Initialize(NULL); + dash::Style dash_style; panel::Style panel_style; |
