From 5bd83df2b50ea766f6050b03fcf79a9895fc31b4 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Wed, 5 Dec 2012 15:15:56 +0800 Subject: Added delta restrainment utility functions, used to restrain a delta point within a particular bounding box, or apply a delta to a point (bzr r2954.2.1) --- unity-shared/DeltaRestrainment-Inl.h | 44 +++++++++++++++++++++++++++++++++ unity-shared/DeltaRestrainment.cpp | 48 ++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 unity-shared/DeltaRestrainment-Inl.h create mode 100644 unity-shared/DeltaRestrainment.cpp (limited to 'unity-shared') diff --git a/unity-shared/DeltaRestrainment-Inl.h b/unity-shared/DeltaRestrainment-Inl.h new file mode 100644 index 000000000..acbbdf636 --- /dev/null +++ b/unity-shared/DeltaRestrainment-Inl.h @@ -0,0 +1,44 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* Compiz unity plugin + * unity.cpp + * + * Copyright (c) 2010-11 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * 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. + * + * Your own copyright notice would go above. You are free to choose whatever + * licence you want, just take note that some compiz code is GPL and you will + * not be able to re-use it if you want to use a different licence. + */ +#ifndef _UNITY_DELTA_RESTRAINMENT_INL_H +#define _UNITY_DELTA_RESTRAINMENT_INL_H + +#include +#include +#include + +namespace unity +{ +namespace util +{ +void restrainDelta (int &dx, + int &dy, + const nux::Geometry &rect, + const nux::Point ¤tPoint); + +void applyDelta (int dx, + int dy, + int &x, + int &y); +} +} + +#endif diff --git a/unity-shared/DeltaRestrainment.cpp b/unity-shared/DeltaRestrainment.cpp new file mode 100644 index 000000000..4d4e635a6 --- /dev/null +++ b/unity-shared/DeltaRestrainment.cpp @@ -0,0 +1,48 @@ +// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- +/* Compiz unity plugin + * unity.cpp + * + * Copyright (c) 2010-11 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * 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. + * + * Your own copyright notice would go above. You are free to choose whatever + * licence you want, just take note that some compiz code is GPL and you will + * not be able to re-use it if you want to use a different licence. + */ +#include +#include +#include "DeltaRestrainment-Inl.h" + +void +unity::util::restrainDelta (int &dx, + int &dy, + const nux::Geometry &rect, + const nux::Point ¤tPoint) +{ + int restrain_x = std::min (0, (rect.x + rect.width) - (currentPoint.x + dx)); + int restrain_y = std::min (0, (rect.y + rect.height) - (currentPoint.y + dy)); + + restrain_x += rect.x - std::min (rect.x, currentPoint.x + dx); + restrain_y += rect.y - std::min (rect.y, currentPoint.y + dy); + + dx += restrain_x; + dy += restrain_y; +} + +void unity::util::applyDelta (int dx, + int dy, + int &x, + int &y) +{ + x += dx; + y += dy; +} -- cgit v1.2.3 From 493ac2282c9fe85da79ccca8fef54f6395b84256 Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Sat, 8 Dec 2012 10:54:24 +0800 Subject: Remove applyDelta - lets move this to nux instead (bzr r2954.2.2) --- unity-shared/DeltaRestrainment.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/DeltaRestrainment.cpp b/unity-shared/DeltaRestrainment.cpp index 4d4e635a6..2903ad623 100644 --- a/unity-shared/DeltaRestrainment.cpp +++ b/unity-shared/DeltaRestrainment.cpp @@ -23,26 +23,17 @@ #include "DeltaRestrainment-Inl.h" void -unity::util::restrainDelta (int &dx, - int &dy, - const nux::Geometry &rect, - const nux::Point ¤tPoint) +unity::util::restrainDelta(int &dx, + int &dy, + nux::Geometry const &rect, + nux::Point const ¤tPoint) { - int restrain_x = std::min (0, (rect.x + rect.width) - (currentPoint.x + dx)); - int restrain_y = std::min (0, (rect.y + rect.height) - (currentPoint.y + dy)); + int restrain_x = std::min(0, (rect.x + rect.width) - (currentPoint.x + dx)); + int restrain_y = std::min(0, (rect.y + rect.height) - (currentPoint.y + dy)); - restrain_x += rect.x - std::min (rect.x, currentPoint.x + dx); - restrain_y += rect.y - std::min (rect.y, currentPoint.y + dy); + restrain_x += rect.x - std::min(rect.x, currentPoint.x + dx); + restrain_y += rect.y - std::min(rect.y, currentPoint.y + dy); dx += restrain_x; dy += restrain_y; } - -void unity::util::applyDelta (int dx, - int dy, - int &x, - int &y) -{ - x += dx; - y += dy; -} -- cgit v1.2.3 From 60af59a1e8886510114da79615e9605083f0c22b Mon Sep 17 00:00:00 2001 From: Sam Spilsbury Date: Tue, 18 Dec 2012 19:40:52 +0800 Subject: Added DeltaRestrainment.cpp to the build (bzr r2954.2.3) --- unity-shared/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'unity-shared') diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 8c5a6c202..467b34698 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -33,6 +33,7 @@ set (UNITY_SHARED_SOURCES DashStyle.cpp DebugDBusInterface.cpp DefaultThumbnailProvider.cpp + DeltaRestrainment.cpp FontSettings.cpp GraphicsUtils.cpp IMTextEntry.cpp -- cgit v1.2.3 From 4f696dc521bcf43eade6a12008d095d7e6399de9 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Tue, 18 Dec 2012 15:09:57 +0200 Subject: Added pch support to unity-shared. (bzr r2998.2.2) --- unity-shared/CMakeLists.txt | 1 + unity-shared/pch/unity-shared_pch.hh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 unity-shared/pch/unity-shared_pch.hh (limited to 'unity-shared') diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 408a5fd0a..7f67753a1 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -83,6 +83,7 @@ endif() add_library (unity-shared STATIC ${UNITY_SHARED_SOURCES}) target_link_libraries (unity-shared ${LIBS}) add_dependencies (unity-shared unity-core-${UNITY_API_VERSION}) +add_pch(pch/unity-shared_pch.hh unity-shared) # # We also need to build compiz specific parts and standalone variants of those parts diff --git a/unity-shared/pch/unity-shared_pch.hh b/unity-shared/pch/unity-shared_pch.hh new file mode 100644 index 000000000..060dbba3c --- /dev/null +++ b/unity-shared/pch/unity-shared_pch.hh @@ -0,0 +1,33 @@ +// -*- 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 . + * + * Authored by: Jussi Pakkanen + */ + +/* + * These are the precompiled header includes for UnityCore. + * Only system header files can be listed here. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include -- cgit v1.2.3 From 22b9a94324c6a823b6aa6470b5c8602bf697dbe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 18 Dec 2012 18:57:48 +0100 Subject: ApplicationManager: remove ApplicationMenu support This is deprecated (bzr r2998.1.1) --- unity-shared/ApplicationManager.h | 10 ---------- unity-shared/BamfApplicationManager.cpp | 21 --------------------- unity-shared/BamfApplicationManager.h | 1 - 3 files changed, 32 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/ApplicationManager.h b/unity-shared/ApplicationManager.h index 7ff8b0ba1..cf74e0c0a 100644 --- a/unity-shared/ApplicationManager.h +++ b/unity-shared/ApplicationManager.h @@ -67,15 +67,6 @@ public: nux::ROProperty urgent; }; -// Used for dbus menus, and nicer than a std::pair of strings. -struct ApplicationMenu -{ - ApplicationMenu(std::string const& path, std::string const& address) - : path(path), remote_address(address) {} - std::string path; - std::string remote_address; -}; - class Application { @@ -94,7 +85,6 @@ public: virtual bool OwnsWindow(Window window_id) const = 0; virtual std::vector GetSupportedMimeTypes() const = 0; - virtual std::vector GetRemoteMenus() const = 0; virtual ApplicationWindowPtr GetFocusableWindow() const = 0; virtual void Focus(bool show_on_visible, int monitor) const = 0; diff --git a/unity-shared/BamfApplicationManager.cpp b/unity-shared/BamfApplicationManager.cpp index 5fcccd8da..1b52b92ff 100644 --- a/unity-shared/BamfApplicationManager.cpp +++ b/unity-shared/BamfApplicationManager.cpp @@ -398,27 +398,6 @@ std::vector Application::GetSupportedMimeTypes() const return result; } -std::vector Application::GetRemoteMenus() const -{ - std::vector result; - std::shared_ptr children(bamf_view_get_children(bamf_view_), g_list_free); - for (GList* l = children.get(); l; l = l->next) - { - if (!BAMF_IS_INDICATOR(l->data)) - continue; - - auto indicator = static_cast(l->data); - const gchar* path = bamf_indicator_get_dbus_menu_path(indicator); - const gchar* address = bamf_indicator_get_remote_address(indicator); - - // It is possible for path or address to be null on error condintions, or if - // the remote is not ready. - if (path && address) - result.push_back(ApplicationMenu(path, address)); - } - return result; -} - ApplicationWindowPtr Application::GetFocusableWindow() const { glib::Object view(bamf_application_get_focusable_child(bamf_app_), diff --git a/unity-shared/BamfApplicationManager.h b/unity-shared/BamfApplicationManager.h index 9823c8e2e..3e0fe1090 100644 --- a/unity-shared/BamfApplicationManager.h +++ b/unity-shared/BamfApplicationManager.h @@ -120,7 +120,6 @@ public: virtual bool OwnsWindow(Window window_id) const; virtual std::vector GetSupportedMimeTypes() const; - virtual std::vector GetRemoteMenus() const; virtual ApplicationWindowPtr GetFocusableWindow() const; virtual void Focus(bool show_on_visible, int monitor) const; -- cgit v1.2.3 From ffe260b0b975aa52ff28fb535aea4e6e24bc7ddf Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Wed, 19 Dec 2012 16:31:44 +0200 Subject: Removed link_libraries from unity-shared. (bzr r3001.1.2) --- unity-shared/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index b4df6d020..6ccd91906 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -9,10 +9,7 @@ set (CFLAGS string (REPLACE ";" " " CFLAGS "${CFLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}") -set (LIBS ${CACHED_UNITY_DEPS_LIBRARIES} ${UNITY_STANDALONE_LADD}) - -set (LIB_PATHS ${CACHED_UNITY_DEPS_LIBRARY_DIRS}) -link_directories (${CMAKE_BINARY_DIR}/UnityCore ${LIB_PATHS}) +set (LIBS ${CACHED_UNITY_DEPS_LDFLAGS} ${UNITY_STANDALONE_LADD}) include_directories (.. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_DIR}) -- cgit v1.2.3