diff options
| author | Thomi Richards <thomi.richards@canonical.com> | 2012-04-11 07:21:14 +1200 |
|---|---|---|
| committer | Thomi Richards <thomi.richards@canonical.com> | 2012-04-11 07:21:14 +1200 |
| commit | 01409242569197d96cab4a36dc735b9c66ecd282 (patch) | |
| tree | 907678897b243dc26f57717a34eb45cb02d9a3ad /plugins | |
| parent | f858d2852ad2c83ef9cb32aad9f48ae487ae7409 (diff) | |
| parent | 63cc2ab8d44bea3b28571e4b6179c72dd4823108 (diff) | |
Merged trunk.
(bzr r2257.3.4)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/unityshell/src/GeisAdapter.cpp | 31 | ||||
| -rw-r--r-- | plugins/unityshell/src/GeisAdapter.h | 9 | ||||
| -rw-r--r-- | plugins/unityshell/src/GestureEngine.cpp | 28 | ||||
| -rw-r--r-- | plugins/unityshell/src/Launcher.cpp | 6 | ||||
| -rw-r--r-- | plugins/unityshell/src/LauncherController.cpp | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/PanelTray.cpp | 6 | ||||
| -rw-r--r-- | plugins/unityshell/src/ResultRendererTile.cpp | 9 | ||||
| -rw-r--r-- | plugins/unityshell/src/ResultRendererTile.h | 1 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 7 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 3 |
10 files changed, 59 insertions, 42 deletions
diff --git a/plugins/unityshell/src/GeisAdapter.cpp b/plugins/unityshell/src/GeisAdapter.cpp index 6d6bae281..d9fe220af 100644 --- a/plugins/unityshell/src/GeisAdapter.cpp +++ b/plugins/unityshell/src/GeisAdapter.cpp @@ -19,21 +19,36 @@ #include <glib.h> #include <gdk/gdkx.h> +#include <NuxCore/Logger.h> #include "GeisAdapter.h" -GeisAdapter* GeisAdapter::_default = 0; +namespace +{ + GeisAdapter* adaptor_instance = nullptr; + nux::logging::Logger logger("unity.geisadapter"); +} /* static */ -GeisAdapter* -GeisAdapter::Default() +GeisAdapter& GeisAdapter::Instance() { - if (!_default) - return _default = new GeisAdapter(); // should be using a dictionary - return _default; + if (!adaptor_instance) + { + LOG_ERROR(logger) << "No GeisAdapter created yet."; + } + + return *adaptor_instance; } GeisAdapter::GeisAdapter() : _root_instance(nullptr) { + if (adaptor_instance) + { + LOG_ERROR(logger) << "More than one GeisAdapter created."; + } + else + { + adaptor_instance = this; + } RegisterRootInstance(); } @@ -41,6 +56,10 @@ GeisAdapter::~GeisAdapter() { if (_root_instance != nullptr) geis_finish(_root_instance); + if (adaptor_instance == this) + { + adaptor_instance = nullptr; + } } void diff --git a/plugins/unityshell/src/GeisAdapter.h b/plugins/unityshell/src/GeisAdapter.h index 72d8ebc9b..f68923bed 100644 --- a/plugins/unityshell/src/GeisAdapter.h +++ b/plugins/unityshell/src/GeisAdapter.h @@ -28,8 +28,9 @@ class GeisAdapter : public sigc::trackable { public: - static GeisAdapter* Default(); + static GeisAdapter& Instance(); + GeisAdapter(); ~GeisAdapter(); void Run(); @@ -142,8 +143,6 @@ public: sigc::signal<void, GeisTouchData*> touch_update; sigc::signal<void, GeisTouchData*> touch_finish; protected: - GeisAdapter(); - static gboolean OnWatchIn(GIOChannel* source, GIOCondition condition, gpointer data); static void InputDeviceAdded(void* cookie, GeisInputDeviceId device_id, void* attrs); @@ -167,11 +166,7 @@ private: void RegisterRootInstance(); GeisInstance _root_instance; - guint _watch_id; - - static GeisAdapter* _default; - }; #endif diff --git a/plugins/unityshell/src/GestureEngine.cpp b/plugins/unityshell/src/GestureEngine.cpp index 7c62372ad..41efe8030 100644 --- a/plugins/unityshell/src/GestureEngine.cpp +++ b/plugins/unityshell/src/GestureEngine.cpp @@ -38,25 +38,25 @@ GestureEngine::GestureEngine(CompScreen* screen) _pinch_grab = 0; _fleur_cursor = XCreateFontCursor (screen->dpy (), XC_fleur); - GeisAdapter* adapter = GeisAdapter::Default(); + GeisAdapter& adapter = GeisAdapter::Instance(); - adapter->tap.connect(sigc::mem_fun(this, &GestureEngine::OnTap)); + adapter.tap.connect(sigc::mem_fun(this, &GestureEngine::OnTap)); - adapter->drag_start.connect(sigc::mem_fun(this, &GestureEngine::OnDragStart)); - adapter->drag_update.connect(sigc::mem_fun(this, &GestureEngine::OnDragUpdate)); - adapter->drag_finish.connect(sigc::mem_fun(this, &GestureEngine::OnDragFinish)); + adapter.drag_start.connect(sigc::mem_fun(this, &GestureEngine::OnDragStart)); + adapter.drag_update.connect(sigc::mem_fun(this, &GestureEngine::OnDragUpdate)); + adapter.drag_finish.connect(sigc::mem_fun(this, &GestureEngine::OnDragFinish)); - adapter->rotate_start.connect(sigc::mem_fun(this, &GestureEngine::OnRotateStart)); - adapter->rotate_update.connect(sigc::mem_fun(this, &GestureEngine::OnRotateUpdate)); - adapter->rotate_finish.connect(sigc::mem_fun(this, &GestureEngine::OnRotateFinish)); + adapter.rotate_start.connect(sigc::mem_fun(this, &GestureEngine::OnRotateStart)); + adapter.rotate_update.connect(sigc::mem_fun(this, &GestureEngine::OnRotateUpdate)); + adapter.rotate_finish.connect(sigc::mem_fun(this, &GestureEngine::OnRotateFinish)); - adapter->pinch_start.connect(sigc::mem_fun(this, &GestureEngine::OnPinchStart)); - adapter->pinch_update.connect(sigc::mem_fun(this, &GestureEngine::OnPinchUpdate)); - adapter->pinch_finish.connect(sigc::mem_fun(this, &GestureEngine::OnPinchFinish)); + adapter.pinch_start.connect(sigc::mem_fun(this, &GestureEngine::OnPinchStart)); + adapter.pinch_update.connect(sigc::mem_fun(this, &GestureEngine::OnPinchUpdate)); + adapter.pinch_finish.connect(sigc::mem_fun(this, &GestureEngine::OnPinchFinish)); - adapter->touch_start.connect(sigc::mem_fun(this, &GestureEngine::OnTouchStart)); - adapter->touch_update.connect(sigc::mem_fun(this, &GestureEngine::OnTouchUpdate)); - adapter->touch_finish.connect(sigc::mem_fun(this, &GestureEngine::OnTouchFinish)); + adapter.touch_start.connect(sigc::mem_fun(this, &GestureEngine::OnTouchStart)); + adapter.touch_update.connect(sigc::mem_fun(this, &GestureEngine::OnTouchUpdate)); + adapter.touch_finish.connect(sigc::mem_fun(this, &GestureEngine::OnTouchFinish)); } GestureEngine::~GestureEngine() diff --git a/plugins/unityshell/src/Launcher.cpp b/plugins/unityshell/src/Launcher.cpp index b257cbdfe..c8bde5ecb 100644 --- a/plugins/unityshell/src/Launcher.cpp +++ b/plugins/unityshell/src/Launcher.cpp @@ -188,7 +188,7 @@ Launcher::Launcher(nux::BaseWindow* parent, 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)); - GeisAdapter& adapter = *(GeisAdapter::Default()); + GeisAdapter& adapter = GeisAdapter::Instance(); adapter.drag_start.connect(sigc::mem_fun(this, &Launcher::OnDragStart)); adapter.drag_update.connect(sigc::mem_fun(this, &Launcher::OnDragUpdate)); adapter.drag_finish.connect(sigc::mem_fun(this, &Launcher::OnDragFinish)); @@ -1596,7 +1596,7 @@ void Launcher::ConfigureBarrier() float decay_responsiveness_mult = ((options()->edge_responsiveness() - 1) * .3f) + 1; float reveal_responsiveness_mult = ((options()->edge_responsiveness() - 1) * .025f) + 1; - + _hide_machine->reveal_pressure = options()->edge_reveal_pressure() * reveal_responsiveness_mult; _hide_machine->edge_decay_rate = options()->edge_decay_rate() * decay_responsiveness_mult; } @@ -1954,7 +1954,7 @@ void Launcher::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) } else { - blur_texture = bg_effect_helper_.GetRegion(blur_geo); + blur_texture = bg_effect_helper_.GetRegion(blur_geo); } if (blur_texture.IsValid()) diff --git a/plugins/unityshell/src/LauncherController.cpp b/plugins/unityshell/src/LauncherController.cpp index 7e0bd8d74..6a490adaa 100644 --- a/plugins/unityshell/src/LauncherController.cpp +++ b/plugins/unityshell/src/LauncherController.cpp @@ -833,6 +833,7 @@ void Controller::Impl::SetupBamf() icon->SetSortPriority(sort_priority_++); RegisterIcon(icon); } + g_list_free(apps); SortAndUpdate(); model_->order_changed.connect(sigc::mem_fun(this, &Impl::SortAndUpdate)); diff --git a/plugins/unityshell/src/PanelTray.cpp b/plugins/unityshell/src/PanelTray.cpp index 728a57d2d..cba7f4ad2 100644 --- a/plugins/unityshell/src/PanelTray.cpp +++ b/plugins/unityshell/src/PanelTray.cpp @@ -85,7 +85,11 @@ PanelTray::~PanelTray() g_strfreev(whitelist_); if (gtk_widget_get_realized(window_)) - gtk_widget_destroy(window_); + { + // We call Release since we're deleting the window here manually, + // and we don't want the smart pointer to try and delete it as well. + gtk_widget_destroy(window_.Release()); + } } Window PanelTray::xid() diff --git a/plugins/unityshell/src/ResultRendererTile.cpp b/plugins/unityshell/src/ResultRendererTile.cpp index 37b4a75d7..aa7d75243 100644 --- a/plugins/unityshell/src/ResultRendererTile.cpp +++ b/plugins/unityshell/src/ResultRendererTile.cpp @@ -103,7 +103,7 @@ void ResultRendererTile::Render(nux::GraphicsEngine& GfxContext, // set up our texture mode nux::TexCoordXForm texxform; - + int icon_left_hand_side = geometry.x + (geometry.width - container->icon->GetWidth()) / 2; int icon_top_side = geometry.y + padding + ((tile_icon_size - container->icon->GetHeight()) / 2); @@ -289,7 +289,7 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t pixbuf_height = gdk_pixbuf_get_height(pixbuf); if (G_UNLIKELY(!pixbuf_height || !pixbuf_width)) { - LOG_ERROR(logger) << "Pixbuf: " << texid << " has a zero height/width: " + LOG_ERROR(logger) << "Pixbuf: " << texid << " has a zero height/width: " << width << "," << height; pixbuf_width = (pixbuf_width) ? pixbuf_width : 1; // no zeros please pixbuf_height = (pixbuf_height) ? pixbuf_height: 1; // no zeros please @@ -304,13 +304,12 @@ nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& t { // slow path for non square icons that must be resized to fit in the square // texture - + Style& style = Style::Instance(); float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 if (aspect < 1.0f) { pixbuf_width = style.GetTileWidth() - (padding * 2); - pixbuf_width = (max_icon_width_ > 0) ? std::min(pixbuf_width, max_icon_width_) : pixbuf_width; pixbuf_height = pixbuf_width * aspect; @@ -412,7 +411,7 @@ void ResultRendererTile::IconLoaded(std::string const& texid, container->icon = texture; container->blurred_icon = texture_blurred; - container->prelight = texture_prelight; + container->prelight = texture_prelight; NeedsRedraw.emit(); diff --git a/plugins/unityshell/src/ResultRendererTile.h b/plugins/unityshell/src/ResultRendererTile.h index 19fa1615c..cf8aaf55b 100644 --- a/plugins/unityshell/src/ResultRendererTile.h +++ b/plugins/unityshell/src/ResultRendererTile.h @@ -89,7 +89,6 @@ protected: void LoadIcon(Result& row); nux::ObjectPtr<nux::BaseTexture> prelight_cache_; nux::ObjectPtr<nux::BaseTexture> normal_cache_; - int max_icon_width_; private: //icon loading callbacks void IconLoaded(std::string const& texid, diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index 349432137..0482e33d3 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -108,7 +108,6 @@ UnityScreen::UnityScreen(CompScreen* screen) , cScreen(CompositeScreen::get(screen)) , gScreen(GLScreen::get(screen)) , enable_shortcut_overlay_(true) - , gestureEngine(nullptr) , wt(nullptr) , panelWindow(nullptr) , debugger(nullptr) @@ -358,8 +357,8 @@ UnityScreen::UnityScreen(CompScreen* screen) g_idle_add_full (G_PRIORITY_DEFAULT, &UnityScreen::initPluginActions, this, NULL); super_keypressed_ = false; - GeisAdapter::Default()->Run(); - gestureEngine = new GestureEngine(screen); + geis_adapter_.Run(); + gesture_engine_.reset(new GestureEngine(screen)); CompString name(PKGDATADIR"/panel-shadow.png"); CompString pname("unityshell"); @@ -380,7 +379,7 @@ UnityScreen::UnityScreen(CompScreen* screen) RaiseInputWindows(); }); - + Display* display = gdk_x11_display_get_xdisplay(gdk_display_get_default());; XSelectInput(display, GDK_ROOT_WINDOW(), PropertyChangeMask); LOG_INFO(logger) << "UnityScreen constructed: " << timer.ElapsedSeconds() << "s"; diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index 4035d7379..8bcfed0ad 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -237,6 +237,7 @@ private: dash::Style dash_style_; panel::Style panel_style_; FontSettings font_settings_; + GeisAdapter geis_adapter_; internal::FavoriteStoreGSettings favorite_store_; launcher::Controller::Ptr launcher_controller_; @@ -249,7 +250,7 @@ private: std::list<shortcut::AbstractHint::Ptr> hints_; bool enable_shortcut_overlay_; - GestureEngine* gestureEngine; + std::unique_ptr<GestureEngine> gesture_engine_; nux::WindowThread* wt; nux::BaseWindow* panelWindow; nux::Geometry lastTooltipArea; |
