From 1b078419d8b38e4b7ddcd4cc4fd7918dd37c4aef Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Wed, 11 Jul 2012 18:30:51 -0700 Subject: * Added gtest for blank icon (bzr r2487.2.4) --- unity-shared/PluginAdapterStandalone.cpp | 49 ++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp index 5708bfbc4..962207076 100644 --- a/unity-shared/PluginAdapterStandalone.cpp +++ b/unity-shared/PluginAdapterStandalone.cpp @@ -124,7 +124,7 @@ MultiActionList::TerminateAll(CompOption::Vector& extraArgs) { } -unsigned long long +unsigned long long PluginAdapter::GetWindowActiveNumber (guint32 xid) { return 0; @@ -264,6 +264,39 @@ PluginAdapter::Minimize(guint32 xid) void PluginAdapter::Close(guint32 xid) { + GdkDisplay* gdkdisplay; + GdkScreen* screen; + Display* xdisplay; + Atom net_close_win; + Window xroot; + XEvent ev; + + gdkdisplay = gdk_display_get_default(); + xdisplay = GDK_DISPLAY_XDISPLAY(gdkdisplay); + screen = gdk_display_get_default_screen (gdkdisplay); + xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); + + net_close_win = XInternAtom (xdisplay, "_NET_CLOSE_WINDOW", 0); + printf("Here\n"); + + ev.xclient.type = ClientMessage; + ev.xclient.display = xdisplay; + + ev.xclient.serial = 0; + ev.xclient.send_event = TRUE; + + ev.xclient.window = xid; + ev.xclient.message_type = net_close_win; + ev.xclient.format = 32; + + ev.xclient.data.l[0] = CurrentTime; + ev.xclient.data.l[1] = 1; //application + + XSendEvent (xdisplay, xroot, FALSE, + SubstructureRedirectMask | SubstructureNotifyMask, + &ev); + + XSync (xdisplay, FALSE); } void @@ -281,18 +314,18 @@ PluginAdapter::Lower(guint32 xid) { } -void +void PluginAdapter::FocusWindowGroup(std::vector window_ids, FocusVisibility focus_visibility, int monitor, bool only_top_win) { } -bool +bool PluginAdapter::ScaleWindowGroup(std::vector windows, int state, bool force) { return false; } -void +void PluginAdapter::SetWindowIconGeometry(Window window, nux::Geometry const& geo) { } @@ -332,14 +365,14 @@ PluginAdapter::GetWindowSavedGeometry(guint32 xid) const return geo; } -nux::Geometry +nux::Geometry PluginAdapter::GetScreenGeometry() const { nux::Geometry geo(0, 0, 1, 1); - return geo; + return geo; } -nux::Geometry +nux::Geometry PluginAdapter::GetWorkAreaGeometry(guint32 xid) const { nux::Geometry geo(0, 0, 1, 1); @@ -352,7 +385,7 @@ PluginAdapter::CheckWindowIntersection(nux::Geometry const& region, CompWindow* return false; } -void +void PluginAdapter::CheckWindowIntersections (nux::Geometry const& region, bool &active, bool &any) { } -- cgit v1.2.3 From 4a94584f5e4e40125e89033b59c50f4707964862 Mon Sep 17 00:00:00 2001 From: Brandon Schaefer Date: Wed, 11 Jul 2012 18:42:41 -0700 Subject: * removed debugging (bzr r2487.2.5) --- unity-shared/PluginAdapterStandalone.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'unity-shared') diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp index 962207076..672d84ac5 100644 --- a/unity-shared/PluginAdapterStandalone.cpp +++ b/unity-shared/PluginAdapterStandalone.cpp @@ -277,7 +277,6 @@ PluginAdapter::Close(guint32 xid) xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); net_close_win = XInternAtom (xdisplay, "_NET_CLOSE_WINDOW", 0); - printf("Here\n"); ev.xclient.type = ClientMessage; ev.xclient.display = xdisplay; -- cgit v1.2.3 From 2d06d9f0a9d5b1c16ae88a718523f0f8df8aa694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Jul 2012 03:06:20 +0200 Subject: IconLoader: replace sigc::slot with std::function Also don't accept requests from invalid slots (bzr r2501.1.4) --- unity-shared/IconLoader.cpp | 19 +++++++++++-------- unity-shared/IconLoader.h | 3 +-- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/IconLoader.cpp b/unity-shared/IconLoader.cpp index d35b24e22..2627d914c 100644 --- a/unity-shared/IconLoader.cpp +++ b/unity-shared/IconLoader.cpp @@ -109,12 +109,15 @@ private: void InvokeSlot() { - slot(data, size, result); + if (slot) + slot(data, size, result); // notify shadow tasks for (auto shadow_task : shadow_tasks) { - shadow_task->slot(shadow_task->data, shadow_task->size, result); + if (shadow_task->slot) + shadow_task->slot(shadow_task->data, shadow_task->size, result); + impl->task_map_.erase(shadow_task->handle); } @@ -373,7 +376,7 @@ int IconLoader::Impl::LoadFromIconName(std::string const& icon_name, unsigned size, IconLoaderCallback slot) { - if (no_load_ || icon_name.empty() || size < MIN_ICON_SIZE) + if (no_load_ || icon_name.empty() || size < MIN_ICON_SIZE || !slot) return 0; // We need to check this because of legacy desktop files @@ -389,7 +392,7 @@ int IconLoader::Impl::LoadFromGIconString(std::string const& gicon_string, unsigned size, IconLoaderCallback slot) { - if (no_load_ || gicon_string.empty() || size < MIN_ICON_SIZE) + if (no_load_ || gicon_string.empty() || size < MIN_ICON_SIZE || !slot) return 0; return ReturnCachedOrQueue(gicon_string, size, slot, REQUEST_TYPE_GICON_STRING); @@ -399,7 +402,7 @@ int IconLoader::Impl::LoadFromFilename(std::string const& filename, unsigned size, IconLoaderCallback slot) { - if (no_load_ || filename.empty() || size < MIN_ICON_SIZE) + if (no_load_ || filename.empty() || size < MIN_ICON_SIZE || !slot) return 0; glib::Object file(::g_file_new_for_path(filename.c_str())); @@ -412,7 +415,7 @@ int IconLoader::Impl::LoadFromURI(std::string const& uri, unsigned size, IconLoaderCallback slot) { - if (no_load_ || uri.empty() || size < MIN_ICON_SIZE) + if (no_load_ || uri.empty() || size < MIN_ICON_SIZE || !slot) return 0; return ReturnCachedOrQueue(uri, size, slot, REQUEST_TYPE_URI); @@ -424,7 +427,7 @@ void IconLoader::Impl::DisconnectHandle(Handle handle) if (iter != task_map_.end()) { - iter->second->slot.disconnect(); + iter->second->slot = nullptr; } } @@ -503,7 +506,7 @@ bool IconLoader::Impl::CacheLookup(std::string const& key, auto iter = cache_.find(key); bool found = iter != cache_.end(); - if (found) + if (found && slot) { glib::Object const& pixbuf = iter->second; slot(data, size, pixbuf); diff --git a/unity-shared/IconLoader.h b/unity-shared/IconLoader.h index bc70705a0..099bf059f 100644 --- a/unity-shared/IconLoader.h +++ b/unity-shared/IconLoader.h @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -33,7 +32,7 @@ namespace unity class IconLoader : public boost::noncopyable { public: - typedef sigc::slot const&> IconLoaderCallback; + typedef std::function const&)> IconLoaderCallback; IconLoader(); ~IconLoader(); -- cgit v1.2.3 From 51ba0301a026a44074ee96d540609f574215ede2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Jul 2012 03:07:29 +0200 Subject: UBusWrapper: replace sigc::slot with std::function Also make UBusConnection struct private and remove the unneeded manager field (bzr r2501.1.5) --- unity-shared/UBusWrapper.cpp | 6 ++++-- unity-shared/UBusWrapper.h | 30 ++++++++++++------------------ 2 files changed, 16 insertions(+), 20 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/UBusWrapper.cpp b/unity-shared/UBusWrapper.cpp index 57da7e031..e1f280092 100644 --- a/unity-shared/UBusWrapper.cpp +++ b/unity-shared/UBusWrapper.cpp @@ -36,8 +36,10 @@ UBusManager::~UBusManager() void UBusManager::RegisterInterest(std::string const& interest_name, UBusManagerCallback slot) { - UBusConnection::Ptr connection (new UBusConnection()); - connection->manager = this; + if (!slot || interest_name.empty()) + return; + + auto connection = std::make_shared(); connection->name = interest_name; connection->slot = slot; connection->id = ubus_server_register_interest(server_, diff --git a/unity-shared/UBusWrapper.h b/unity-shared/UBusWrapper.h index 1b9c043e0..c18ff0a79 100644 --- a/unity-shared/UBusWrapper.h +++ b/unity-shared/UBusWrapper.h @@ -22,45 +22,39 @@ #include #include #include - -#include +#include #include "ubus-server.h" namespace unity { -class UBusManager +class UBusManager : public boost::noncopyable { public: - typedef sigc::slot UBusManagerCallback; + typedef std::function UBusManagerCallback; + + UBusManager(); + ~UBusManager(); + void RegisterInterest(std::string const& interest_name, UBusManagerCallback slot); + void UnregisterInterest(std::string const& interest_name); + void SendMessage(std::string const& message_name, GVariant* args = NULL); + +private: struct UBusConnection { - public: typedef std::shared_ptr Ptr; - UBusManager* manager; std::string name; UBusManagerCallback slot; guint id; }; - typedef std::vector Connections; - UBusManager(); - ~UBusManager(); - - void RegisterInterest(std::string const& interest_name, - UBusManagerCallback slot); - void UnregisterInterest(std::string const& interest_name); - void SendMessage(std::string const& message_name, GVariant* args = NULL); - -private: static void OnCallback(GVariant* args, gpointer user_data); -private: UBusServer* server_; - Connections connections_; + std::vector connections_; }; } -- cgit v1.2.3 From f6ea85baaeb758cb58a310ba9e2a3369748e2bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Jul 2012 03:08:04 +0200 Subject: TextureCache: replace sigc::slot with std::function (bzr r2501.1.6) --- unity-shared/TextureCache.cpp | 3 +++ unity-shared/TextureCache.h | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/TextureCache.cpp b/unity-shared/TextureCache.cpp index 53004fc7a..0d19d5cef 100644 --- a/unity-shared/TextureCache.cpp +++ b/unity-shared/TextureCache.cpp @@ -55,6 +55,9 @@ TextureCache::BaseTexturePtr TextureCache::FindTexture(std::string const& textur int width, int height, CreateTextureCallback slot) { + if (!slot) + return BaseTexturePtr(); + std::string key = Hash(texture_id, width, height); BaseTexturePtr texture(cache_[key]); diff --git a/unity-shared/TextureCache.h b/unity-shared/TextureCache.h index 79fa34c32..5cc569abb 100644 --- a/unity-shared/TextureCache.h +++ b/unity-shared/TextureCache.h @@ -25,8 +25,6 @@ #include #include - -#include #include /* A simple texture cache system, you ask the cache for a texture by id if the @@ -43,7 +41,7 @@ public: typedef nux::ObjectPtr BaseTexturePtr; // id, width, height -> texture - typedef sigc::slot CreateTextureCallback; + typedef std::function CreateTextureCallback; static TextureCache& GetDefault(); -- cgit v1.2.3 From afaa3f3534f3445c3411948988a3832e8cd40b45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Jul 2012 03:09:28 +0200 Subject: Fix various code depending on sigc::slot (bzr r2501.1.7) --- unity-shared/FontSettings.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'unity-shared') diff --git a/unity-shared/FontSettings.cpp b/unity-shared/FontSettings.cpp index 24c31e8a1..1b115f8e1 100644 --- a/unity-shared/FontSettings.cpp +++ b/unity-shared/FontSettings.cpp @@ -21,6 +21,7 @@ #include #include +#include namespace unity { -- cgit v1.2.3 From 01245f71bd6d11535d55ec1a07ba92c4605cb5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 16 Jul 2012 20:43:20 +0200 Subject: PluginAdapterStandalone: remove the unneeded close implementation (bzr r2503.1.2) --- unity-shared/PluginAdapterStandalone.cpp | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'unity-shared') diff --git a/unity-shared/PluginAdapterStandalone.cpp b/unity-shared/PluginAdapterStandalone.cpp index 672d84ac5..45d0d5723 100644 --- a/unity-shared/PluginAdapterStandalone.cpp +++ b/unity-shared/PluginAdapterStandalone.cpp @@ -264,38 +264,6 @@ PluginAdapter::Minimize(guint32 xid) void PluginAdapter::Close(guint32 xid) { - GdkDisplay* gdkdisplay; - GdkScreen* screen; - Display* xdisplay; - Atom net_close_win; - Window xroot; - XEvent ev; - - gdkdisplay = gdk_display_get_default(); - xdisplay = GDK_DISPLAY_XDISPLAY(gdkdisplay); - screen = gdk_display_get_default_screen (gdkdisplay); - xroot = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen)); - - net_close_win = XInternAtom (xdisplay, "_NET_CLOSE_WINDOW", 0); - - ev.xclient.type = ClientMessage; - ev.xclient.display = xdisplay; - - ev.xclient.serial = 0; - ev.xclient.send_event = TRUE; - - ev.xclient.window = xid; - ev.xclient.message_type = net_close_win; - ev.xclient.format = 32; - - ev.xclient.data.l[0] = CurrentTime; - ev.xclient.data.l[1] = 1; //application - - XSendEvent (xdisplay, xroot, FALSE, - SubstructureRedirectMask | SubstructureNotifyMask, - &ev); - - XSync (xdisplay, FALSE); } void -- cgit v1.2.3